MCPcopy Create free account
hub / github.com/bootc-dev/bootc / parse_shadow_content

Function parse_shadow_content

crates/sysusers/src/nameservice/shadow.rs:87–108  ·  view source on GitHub ↗
(content: impl BufRead)

Source from the content-addressed store, hash-verified

85}
86
87pub fn parse_shadow_content(content: impl BufRead) -> Result<Vec<ShadowEntry>> {
88 let mut entries = vec![];
89 for (line_num, line) in content.lines().enumerate() {
90 let input =
91 line.with_context(|| format!("failed to read shadow entry at line {line_num}"))?;
92
93 // Skip empty and comment lines
94 if input.is_empty() || input.starts_with('#') {
95 continue;
96 }
97
98 let entry = ShadowEntry::parse_line(&input).ok_or_else(|| {
99 anyhow!(
100 "failed to parse shadow entry at line {}, content: {}",
101 line_num,
102 &input
103 )
104 })?;
105 entries.push(entry);
106 }
107 Ok(entries)
108}
109
110#[cfg(test)]
111mod tests {

Callers 1

test_parse_linesFunction · 0.85

Calls 1

is_emptyMethod · 0.45

Tested by 1

test_parse_linesFunction · 0.68