[][src]Crate whoami

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(), and platform() which return enums). The following example shows how to use all of the functions (except those that return OsString):

fn main() {
    println!(
        "User→Name      whoami::realname():    {}",
        whoami::realname()
    );
    println!(
        "User→Username  whoami::username():    {}",
        whoami::username()
    );
    println!(
        "Host→Name      whoami::devicename():  {}",
        whoami::devicename()
    );
    println!(
        "Host→Hostname  whoami::hostname():    {}",
        whoami::hostname()
    );
    println!(
        "Platform       whoami::platform():    {}",
        whoami::platform()
    );
    println!(
        "OS Distro      whoami::distro():      {}",
        whoami::distro()
    );
    println!(
        "Desktop Env.   whoami::desktop_env(): {}",
        whoami::desktop_env()
    );
}

Enums

DesktopEnv

Which Desktop Environment

Platform

Which Platform

Functions

desktop_env

Get the desktop environment.

devicename

Get the device name (also known as "Pretty Name"), used to identify device for bluetooth pairing.

devicename_os

Get the device name (also known as "Pretty Name"), used to identify device for bluetooth pairing.

distro

Get the name of the operating system distribution and (possibly) version.

distro_os

Get the name of the operating system distribution and (possibly) version.

hostname

Get the host device's hostname.

hostname_os

Get the host device's hostname.

platform

Get the platform.

realname

Get the user's real name.

realname_os

Get the user's real name.

username

Get the user's username.

username_os

Get the user's username.