Expand description
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()
, platform()
, and arch()
, which
return enums, and langs()
that returns an iterator of String
s). The
following example shows how to use all of the functions (except those that
return OsString
):
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(),
);
println!(
"Device's CPU Arch whoami::arch(): {}",
whoami::arch(),
);
Modules§
- fallible
- Fallible versions of the whoami APIs.
Enums§
- Arch
- The architecture of a CPU
- Country
- Country code for a
Language
dialect - Desktop
Env - The desktop environment of a system
- Language
- A spoken language
- Platform
- The underlying platform for a system
- Width
- The address width of a CPU architecture
Functions§
- arch
- Get the CPU Architecture.
- desktop_
env - Get the desktop environment.
- devicename
- Get the device name (also known as “Pretty Name”).
- devicename_
os - Get the device name (also known as “Pretty Name”).
- distro
- Get the name of the operating system distribution and (possibly) version.
- distro_
os Deprecated - Get the name of the operating system distribution and (possibly) version.
- hostname
Deprecated - Get the host device’s hostname.
- hostname_
os Deprecated - Get the host device’s hostname.
- lang
Deprecated - Get the user’s preferred language(s).
- langs
- Get the user’s preferred language(s).
- platform
- Get the platform.
- realname
- Get the user’s real (full) name.
- realname_
os - Get the user’s real (full) name.
- username
- Get the user’s username.
- username_
os - Get the user’s username.