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

Method parse_line

crates/sysusers/src/nameservice/group.rs:19–31  ·  view source on GitHub ↗

Parse a single group entry.

(s: impl AsRef<str>)

Source from the content-addressed store, hash-verified

17impl GroupEntry {
18 /// Parse a single group entry.
19 pub fn parse_line(s: impl AsRef<str>) -> Option<Self> {
20 let mut parts = s.as_ref().splitn(4, ':');
21 let entry = Self {
22 name: parts.next()?.to_string(),
23 passwd: parts.next()?.to_string(),
24 gid: parts.next().and_then(|s| s.parse().ok())?,
25 users: {
26 let users = parts.next()?;
27 users.split(',').map(String::from).collect()
28 },
29 };
30 Some(entry)
31 }
32
33 /// Serialize entry to writer, as a group line.
34 pub fn to_writer(&self, writer: &mut impl Write) -> Result<()> {

Callers

nothing calls this directly

Calls 3

as_refMethod · 0.45
nextMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected