Crate whoami

source
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 Strings or OsStrings (with the exception of desktop_env(), platform(), and arch(), which return enums, and langs() that returns an iterator of Strings). 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 versions of the whoami APIs.

Enums§

Functions§

  • Get the CPU Architecture.
  • Get the desktop environment.
  • Get the device name (also known as “Pretty Name”).
  • Get the device name (also known as “Pretty Name”).
  • Get the name of the operating system distribution and (possibly) version.
  • distro_osDeprecated
    Get the name of the operating system distribution and (possibly) version.
  • hostnameDeprecated
    Get the host device’s hostname.
  • hostname_osDeprecated
    Get the host device’s hostname.
  • langDeprecated
    Get the user’s preferred language(s).
  • Get the user’s preferred language(s).
  • Get the platform.
  • Get the user’s real (full) name.
  • Get the user’s real (full) name.
  • Get the user’s username.
  • Get the user’s username.

Type Aliases§