pub const LINUX: bool = cfg!(target_os="linux");
pub const WINDOWS: bool = cfg!(target_os="windows");
pub const MACOS: bool = cfg!(target_os="macos");
pub const ANDROID: bool = cfg!(target_os="android");
pub const IOS: bool = cfg!(target_os="ios");
pub const FREEBSD: bool = cfg!(target_os="freebsd");
pub const DRAGONFLY: bool = cfg!(target_os="dragonfly");
pub const OPENBSD: bool = cfg!(target_os="openbsd");
pub const NONE: bool = cfg!(target_os="none");
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct cfg_target_os_info {
pub linux: bool,
pub windows: bool,
pub macos: bool,
pub android: bool,
pub ios: bool,
pub freebsd: bool,
pub dragonfly: bool,
pub openbsd: bool,
pub none: bool,
}
pub const ALL_INFO: cfg_target_os_info = all_info();
pub const fn all_info() -> cfg_target_os_info {
cfg_target_os_info {
linux: LINUX,
windows: WINDOWS,
macos: MACOS,
android: ANDROID,
ios: IOS,
freebsd: FREEBSD,
dragonfly: DRAGONFLY,
openbsd: OPENBSD,
none: NONE,
}
}
#[cfg(feature = "json")]
impl cfg_target_os_info {
pub fn to_json(&self) -> serde_json::Value {
serde_json::json!({
"linux": self.linux,
"windows": self.windows,
"macos": self.macos,
"android": self.android,
"ios": self.ios,
"freebsd": self.freebsd,
"dragonfly": self.dragonfly,
"openbsd": self.openbsd,
"none": self.none,
})
}
}