logo
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 (with the exception of env, which returns an enum). The following example shows how to use all of the functions:

fn main() {
    print!(
        "--------------------------------------\n\
         user's full name (user):              {}\n\
         username (username):                  {}\n\
         --------------------------------------\n\
         host's fancy name (host):             {}\n\
         hostname (hostname):                  {}\n\
         --------------------------------------\n\
         platform (platform):                  {}\n\
         operating system (os):                {}\n\
         desktop environment (env):            {}\n\
         --------------------------------------\n\
         ",
        whoami::user(),
        whoami::username(),
        whoami::host(),
        whoami::hostname(),
        whoami::platform(),
        whoami::os(),
        whoami::env(),
    );
}

Enums

Which Desktop Environment
Which Platform

Functions

Get the desktop environment.
Get the host device’s (pretty) name.
Get the host device’s hostname.
Get the the operating system name and version.
Get the platform.
Get the user’s full name.
Get the user’s username.