Trait sysinfo::UserExt [−][src]
pub trait UserExt: Debug { fn get_uid(&self) -> Uid; fn get_gid(&self) -> Gid; fn get_name(&self) -> &str; fn get_groups(&self) -> &[String]; }
Expand description
Getting information for a user.
It is returned from SystemExt::get_users
.
use sysinfo::{System, SystemExt, UserExt}; let mut s = System::new_all(); for user in s.get_users() { println!("{} is in {} groups", user.get_name(), user.get_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.get_users() { println!("{}", *user.get_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.get_users() { println!("{}", *user.get_gid()); }
Returns the name of the user.
use sysinfo::{System, SystemExt, UserExt}; let mut s = System::new_all(); for user in s.get_users() { println!("{}", user.get_name()); }
fn get_groups(&self) -> &[String]
[src]
fn get_groups(&self) -> &[String]
[src]Returns the groups of the user.
use sysinfo::{System, SystemExt, UserExt}; let mut s = System::new_all(); for user in s.get_users() { println!("{} is in {:?}", user.get_name(), user.get_groups()); }