pub trait UserExt: Debug {
// Required methods
fn id(&self) -> &Uid;
fn group_id(&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§
sourcefn id(&self) -> &Uid
fn id(&self) -> &Uid
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.id());
}
sourcefn group_id(&self) -> Gid
fn group_id(&self) -> Gid
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.group_id());
}