#![warn(missing_docs)]
#![doc(
html_logo_url = "https://free.plopgrizzly.com/whoami/icon.svg",
html_favicon_url = "https://free.plopgrizzly.com/whoami/icon.svg",
html_root_url = "http://free.plopgrizzly.com/whoami/"
)]
#[allow(missing_docs)]
pub enum DesktopEnv {
Gnome,
Windows,
Lxde,
Openbox,
Mate,
Xfce,
Kde,
Cinnamon,
I3,
Mac,
Ios,
Android,
Wasm,
Console,
Ubuntu,
Dive,
Fuchsia,
Redox,
Unknown(String),
}
impl ::std::fmt::Display for DesktopEnv {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
use self::DesktopEnv::*;
write!(
f,
"{}",
match self {
Gnome => "gnome".to_string(),
Windows => "windows".to_string(),
Lxde => "lxde".to_string(),
Openbox => "openbox".to_string(),
Mate => "mate".to_string(),
Xfce => "xfce".to_string(),
Kde => "kde".to_string(),
Cinnamon => "cinnamon".to_string(),
I3 => "i3".to_string(),
Mac => "mac".to_string(),
Ios => "ios".to_string(),
Android => "android".to_string(),
Wasm => "wasm".to_string(),
Console => "console".to_string(),
Ubuntu => "ubuntu".to_string(),
Dive => "dive".to_string(),
Fuchsia => "fuchsia".to_string(),
Redox => "redox".to_string(),
Unknown(a) => format!("Unknown: \"{}\"", a),
}
)
}
}
#[allow(missing_docs)]
pub enum Platform {
Linux,
FreeBsd,
Windows,
MacOS,
Ios,
Android,
Nintendo,
Xbox,
PlayStation,
Web,
Dive,
Fuchsia,
Redox,
Unknown(String),
}
impl ::std::fmt::Display for Platform {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
use self::Platform::*;
write!(
f,
"{}",
match self {
Linux => "Linux".to_string(),
FreeBsd => "Free BSD".to_string(),
Windows => "Windows".to_string(),
MacOS => "Mac OS".to_string(),
Ios => "iOS".to_string(),
Android => "Android".to_string(),
Nintendo => "Nintendo".to_string(),
Xbox => "XBox".to_string(),
PlayStation => "PlayStation".to_string(),
Web => "Web".to_string(),
Dive => "Dive".to_string(),
Fuchsia => "Fuchsia".to_string(),
Redox => "Redox".to_string(),
Unknown(a) => format!("Unknown: \"{}\"", a),
}
)
}
}
#[cfg(not(target_os = "windows"))]
mod unix;
#[cfg(not(target_os = "windows"))]
use self::unix as native;
#[cfg(target_os = "windows")]
mod windows;
#[cfg(target_os = "windows")]
use self::windows as native;
#[inline(always)]
pub fn username() -> String {
native::username()
}
#[inline(always)]
pub fn user() -> String {
native::realname()
}
#[inline(always)]
pub fn host() -> String {
native::computer()
}
#[inline(always)]
pub fn hostname() -> String {
native::hostname()
}
#[inline(always)]
pub fn os() -> String {
native::os()
}
#[inline(always)]
pub fn env() -> DesktopEnv {
native::env()
}
#[inline(always)]
pub const fn platform() -> Platform {
native::platform()
}