Crate for getting the user's username, realname and environment.
Getting Started
Using the whoami crate is super easy! All of the public items are simple
functions with no parameters that return String
s or
OsString
s (with the exception of
desktop_env()
, and platform()
which return enums, and lang()
that returns an iterator of
String
s). The following example shows how to use
all of the functions (except those that return
OsString
):
fn main() {
println!(
"User's Name whoami::realname(): {}",
whoami::realname()
);
println!(
"User's Username whoami::username(): {}",
whoami::username()
);
println!(
"User's Language whoami::lang(): {:?}",
whoami::lang().collect::<Vec<String>>()
);
println!(
"Device's Pretty Name whoami::devicename(): {}",
whoami::devicename()
);
println!(
"Device's Hostname whoami::hostname(): {}",
whoami::hostname()
);
println!(
"Device's Platform whoami::platform(): {}",
whoami::platform()
);
println!(
"Device's OS Distro whoami::distro(): {}",
whoami::distro()
);
println!(
"Device's Desktop Env. whoami::desktop_env(): {}",
whoami::desktop_env()
);
}