use std::fmt::{self, Display, Formatter}; /// A list of supported operating system types. #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] #[allow(non_camel_case_types, clippy::upper_case_acronyms)] #[non_exhaustive] pub enum Type { /// Alpaquita Linux (). Alpaquita, /// Alpine Linux (). Alpine, /// Amazon Linux AMI (). Amazon, /// Android (). Android, /// Arch Linux (). Arch, /// Artix Linux (). Artix, /// CentOS (). CentOS, /// Debian (). Debian, /// DragonFly BSD (). DragonFly, /// Emscripten (). Emscripten, /// EndeavourOS (). EndeavourOS, /// Fedora (). Fedora, /// FreeBSD (). FreeBSD, /// Garuda Linux () Garuda, /// Gentoo Linux (). Gentoo, /// HardenedBSD (https://hardenedbsd.org/). HardenedBSD, /// Illumos (https://en.wikipedia.org/wiki/Illumos). Illumos, /// Linux based operating system (). Linux, /// Mabox (). Mabox, /// Mac OS X/OS X/macOS (). Macos, /// Manjaro (). Manjaro, /// Mariner (). Mariner, /// MidnightBSD (). MidnightBSD, /// Mint (). Mint, /// NetBSD (). NetBSD, /// NixOS (). NixOS, /// OpenBSD (). OpenBSD, /// OpenCloudOS (). OpenCloudOS, /// openEuler (). openEuler, /// openSUSE (). openSUSE, /// Oracle Linux (). OracleLinux, /// Pop!_OS () Pop, /// Raspberry Pi OS (). Raspbian, /// Red Hat Linux (). Redhat, /// Red Hat Enterprise Linux (). RedHatEnterprise, /// Redox (). Redox, /// Solus (). Solus, /// SUSE Linux Enterprise Server (). SUSE, /// Ubuntu (). Ubuntu, /// Unknown operating system. Unknown, /// Windows (). Windows, } impl Default for Type { fn default() -> Self { Type::Unknown } } impl Display for Type { fn fmt(&self, f: &mut Formatter) -> fmt::Result { match *self { Type::Alpaquita => write!(f, "Alpaquita Linux"), Type::Alpine => write!(f, "Alpine Linux"), Type::Amazon => write!(f, "Amazon Linux AMI"), Type::Arch => write!(f, "Arch Linux"), Type::Artix => write!(f, "Artix Linux"), Type::DragonFly => write!(f, "DragonFly BSD"), Type::Garuda => write!(f, "Garuda Linux"), Type::Gentoo => write!(f, "Gentoo Linux"), Type::Illumos => write!(f, "illumos"), Type::Macos => write!(f, "Mac OS"), Type::MidnightBSD => write!(f, "Midnight BSD"), Type::Mint => write!(f, "Linux Mint"), Type::Pop => write!(f, "Pop!_OS"), Type::Raspbian => write!(f, "Raspberry Pi OS"), Type::Redhat => write!(f, "Red Hat Linux"), Type::RedHatEnterprise => write!(f, "Red Hat Enterprise Linux"), Type::SUSE => write!(f, "SUSE Linux Enterprise Server"), _ => write!(f, "{self:?}"), } } } #[cfg(test)] mod tests { use super::*; use pretty_assertions::assert_eq; #[test] fn default() { assert_eq!(Type::Unknown, Type::default()); } #[test] fn display() { let data = [ (Type::Alpaquita, "Alpaquita Linux"), (Type::Alpine, "Alpine Linux"), (Type::Amazon, "Amazon Linux AMI"), (Type::Android, "Android"), (Type::Arch, "Arch Linux"), (Type::Artix, "Artix Linux"), (Type::CentOS, "CentOS"), (Type::Debian, "Debian"), (Type::DragonFly, "DragonFly BSD"), (Type::Emscripten, "Emscripten"), (Type::EndeavourOS, "EndeavourOS"), (Type::Fedora, "Fedora"), (Type::Garuda, "Garuda Linux"), (Type::Gentoo, "Gentoo Linux"), (Type::FreeBSD, "FreeBSD"), (Type::Linux, "Linux"), (Type::Macos, "Mac OS"), (Type::Manjaro, "Manjaro"), (Type::Mint, "Linux Mint"), (Type::NetBSD, "NetBSD"), (Type::NixOS, "NixOS"), (Type::OpenBSD, "OpenBSD"), (Type::openSUSE, "openSUSE"), (Type::OracleLinux, "OracleLinux"), (Type::Pop, "Pop!_OS"), (Type::Raspbian, "Raspberry Pi OS"), (Type::Redhat, "Red Hat Linux"), (Type::RedHatEnterprise, "Red Hat Enterprise Linux"), (Type::Redox, "Redox"), (Type::Solus, "Solus"), (Type::SUSE, "SUSE Linux Enterprise Server"), (Type::Ubuntu, "Ubuntu"), (Type::Unknown, "Unknown"), (Type::Windows, "Windows"), ]; for (t, expected) in &data { assert_eq!(&t.to_string(), expected); } } }