Function pwd_grp::getpwuid

source ·
pub fn getpwuid(uid: uid_t) -> Result<Option<Passwd<String>>>
Expand description

Look up a passwd entry by uid

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::getpwuid(0).unwrap().unwrap();
assert_eq!(entry.uid, 0);