#[non_exhaustive]pub enum OsType {
Show 17 variants
LINUX,
MACOS,
WINDOWS,
FREEBSD,
OPENBSD,
NETBSD,
DRAGONFLY,
SOLARIS,
ILLUMOS,
ANDROID,
IOS,
REDOX,
FUCHSIA,
HERMIT,
VXWORKS,
AIX,
HAIKU,
}sys only.Expand description
Operating system type.
This enum provides type-safe operating system identifiers. All variants are validated at construction time.
§Invariants
- All variants represent valid operating systems
- OS type is determined at compile time for
current()method
§Examples
use bare_types::sys::OsType;
// Use predefined constants
let os = OsType::LINUX;
assert!(os.is_unix());
// Get current OS
let current = OsType::current();
println!("Running on: {}", current);
// Convert to string representation
assert_eq!(OsType::LINUX.as_str(), "linux");Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
LINUX
GNU/Linux distributions
MACOS
macOS (formerly OS X)
WINDOWS
Microsoft Windows
FREEBSD
FreeBSD operating system
OPENBSD
OpenBSD operating system
NETBSD
NetBSD operating system
DRAGONFLY
DragonFly BSD
SOLARIS
Oracle Solaris
ILLUMOS
Illumos-based systems (OpenIndiana, SmartOS, etc.)
ANDROID
Android mobile OS
IOS
Apple iOS
REDOX
Redox OS (Rust-based microkernel)
FUCHSIA
Google Fuchsia
HERMIT
HermitCore unikernel
VXWORKS
Wind River VxWorks
AIX
IBM AIX
HAIKU
Haiku OS (BeOS-inspired)
Implementations§
Source§impl OsType
impl OsType
Sourcepub const fn current() -> Self
pub const fn current() -> Self
Returns the current operating system (compile-time constant).
This method returns the operating system the code was compiled for, not necessarily the OS of the host system (especially relevant for cross-compilation).
§Examples
use bare_types::sys::OsType;
let os = OsType::current();
println!("Compiled for: {}", os);Sourcepub const fn as_str(&self) -> &'static str
pub const fn as_str(&self) -> &'static str
Returns the string representation of this OS.
§Examples
use bare_types::sys::OsType;
assert_eq!(OsType::LINUX.as_str(), "linux");
assert_eq!(OsType::MACOS.as_str(), "macos");
assert_eq!(OsType::WINDOWS.as_str(), "windows");Sourcepub const fn is_unix(&self) -> bool
pub const fn is_unix(&self) -> bool
Returns true if this is a Unix-like operating system.
§Examples
use bare_types::sys::OsType;
assert!(OsType::LINUX.is_unix());
assert!(OsType::MACOS.is_unix());
assert!(OsType::FREEBSD.is_unix());
assert!(!OsType::WINDOWS.is_unix());Sourcepub const fn is_bsd(&self) -> bool
pub const fn is_bsd(&self) -> bool
Returns true if this is a BSD operating system.
§Examples
use bare_types::sys::OsType;
assert!(OsType::FREEBSD.is_bsd());
assert!(OsType::OPENBSD.is_bsd());
assert!(OsType::NETBSD.is_bsd());
assert!(OsType::DRAGONFLY.is_bsd());
assert!(OsType::MACOS.is_bsd());
assert!(!OsType::LINUX.is_bsd());
assert!(!OsType::WINDOWS.is_bsd());Sourcepub const fn is_windows(&self) -> bool
pub const fn is_windows(&self) -> bool
Returns true if this is Microsoft Windows.
§Examples
use bare_types::sys::OsType;
assert!(OsType::WINDOWS.is_windows());
assert!(!OsType::LINUX.is_windows());
assert!(!OsType::MACOS.is_windows());Sourcepub const fn is_mobile(&self) -> bool
pub const fn is_mobile(&self) -> bool
Returns true if this is a mobile operating system.
§Examples
use bare_types::sys::OsType;
assert!(OsType::ANDROID.is_mobile());
assert!(OsType::IOS.is_mobile());
assert!(!OsType::LINUX.is_mobile());
assert!(!OsType::WINDOWS.is_mobile());Sourcepub const fn is_desktop(&self) -> bool
pub const fn is_desktop(&self) -> bool
Returns true if this is a desktop operating system.
§Examples
use bare_types::sys::OsType;
assert!(OsType::LINUX.is_desktop());
assert!(OsType::MACOS.is_desktop());
assert!(OsType::WINDOWS.is_desktop());
assert!(!OsType::ANDROID.is_desktop());
assert!(!OsType::IOS.is_desktop());Sourcepub const fn is_embedded(&self) -> bool
pub const fn is_embedded(&self) -> bool
Returns true if this is an embedded/real-time operating system.
§Examples
use bare_types::sys::OsType;
assert!(OsType::VXWORKS.is_embedded());
assert!(!OsType::LINUX.is_embedded());Sourcepub const fn is_microkernel(&self) -> bool
pub const fn is_microkernel(&self) -> bool
Returns true if this is a microkernel-based operating system.
§Examples
use bare_types::sys::OsType;
assert!(OsType::REDOX.is_microkernel());
assert!(OsType::FUCHSIA.is_microkernel());
assert!(!OsType::LINUX.is_microkernel());Sourcepub const fn is_posix(&self) -> bool
pub const fn is_posix(&self) -> bool
Returns true if this OS supports POSIX APIs.
§Examples
use bare_types::sys::OsType;
assert!(OsType::LINUX.is_posix());
assert!(OsType::MACOS.is_posix());
assert!(!OsType::WINDOWS.is_posix());Sourcepub const fn is_tier1(&self) -> bool
pub const fn is_tier1(&self) -> bool
Returns true if this is a tier 1 supported Rust target.
Tier 1 targets are guaranteed to work with Rust.
§Examples
use bare_types::sys::OsType;
assert!(OsType::LINUX.is_tier1());
assert!(OsType::MACOS.is_tier1());
assert!(OsType::WINDOWS.is_tier1());
// Tier 2/3 targets return false
// assert!(!OsType::FREEBSD.is_tier1());Trait Implementations§
Source§impl<'arbitrary> Arbitrary<'arbitrary> for OsType
impl<'arbitrary> Arbitrary<'arbitrary> for OsType
Source§fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured this type
needs to construct itself. Read more