Function pwd_grp::getgrnam

source ·
pub fn getgrnam(name: impl AsRef<str>) -> Result<Option<Group<String>>>
Expand description

Look up a group entry by name

Returns None if the entry isn’t found, or Err if an error occurred.

If the entry contains strings that aren’t valid UTF-8, this is treated as an error. If you need to handle non-UTF-8 password/group entries, use the generic trait methods on PwdGrp.

Example

let entry = pwd_grp::getgrnam("root").unwrap().unwrap();
assert_eq!(entry.gid, 0);