Trait sysinfo::UserExt [−][src]
pub trait UserExt: Debug { fn uid(&self) -> Uid; fn gid(&self) -> Gid; fn name(&self) -> &str; fn groups(&self) -> &[String]; }
Expand description
Getting information for a user.
It is returned from SystemExt::users
.
use sysinfo::{System, SystemExt, UserExt}; let mut s = System::new_all(); for user in s.users() { println!("{} is in {} groups", user.name(), user.groups().len()); }
Required methods
Return the user id of the user.
use sysinfo::{System, SystemExt, UserExt}; let mut s = System::new_all(); for user in s.users() { println!("{}", *user.uid()); }
Return the group id of the user.
NOTE - On Windows, this value defaults to 0. Windows doesn’t have a username
specific group assigned to the user.
They do however have unique Security Identifiers
made up of various Components.
Pieces of the SID may be a candidate for this field, but it doesn’t map well to a single group id.
use sysinfo::{System, SystemExt, UserExt}; let mut s = System::new_all(); for user in s.users() { println!("{}", *user.gid()); }
Returns the name of the user.
use sysinfo::{System, SystemExt, UserExt}; let mut s = System::new_all(); for user in s.users() { println!("{}", user.name()); }