Skip to main content

Os

Enum Os 

Source
pub enum Os {
    Linux,
    MacOs,
    IOs,
    Windows,
    FreeBsd,
    NetBsd,
    OpenBsd,
    Illumos,
    Wasi,
    None,
}
Expand description

An operating system, in the sense of the thing that defines the syscall interface, the object format, the start files and the availability of a declaration.

Android is not here. It is a Linux kernel with a different libc, so it is Os::Linux with Env::Android, which is also how GCC and LLVM spell it. The rule is that the OS field answers “whose kernel” and the environment field answers “whose libc”, and Android is the case that shows they are separate questions.

Variants§

§

Linux

Linux. Every libc in the environment field is reachable from here.

§

MacOs

macOS.

§

IOs

iOS. A different OS from macOS and not a variant of it: a different platform value in LC_BUILD_VERSION, a different set of availability macros, and a different SDK.

§

Windows

Windows, either environment.

§

FreeBsd

FreeBSD 14 and later.

§

NetBsd

NetBSD 10.1 and later.

§

OpenBsd

OpenBSD. Dynamically linked libc only, because OpenBSD does not ship a static one and breaks its libc ABI on purpose at every release.

§

Illumos

illumos. In scope because it is open, which is the whole of the argument.

§

Wasi

WASI. The preview number lives in the OS version, because wasip1 and wasip3 are different ABIs rather than different releases of one.

§

None

No operating system. Freestanding, which is the kernel target and the embedded target and the only row in the matrix that has to reach tier 1 without a libc.

Implementations§

Source§

impl Os

Source

pub const fn as_str(self) -> &'static str

The canonical name, without the version.

Source

pub const fn object_format(self) -> Option<ObjectFormat>

The object format this OS uses. There is exactly one per OS, which is why this is a function of the OS and not a field anybody sets.

The freestanding case is the exception and it is handled in crate::TargetTuple, because a freestanding target’s format follows its architecture: a wasm freestanding target emits wasm and an aarch64 one emits ELF.

Source

pub const fn is_darwin(self) -> bool

Whether this is one of the Darwin systems, which share a kernel, a linker, a set of ABI divergences from AAPCS64 and a licence that stops us shipping their headers.

Source

pub const fn has_selectable_libc(self) -> bool

Whether a program on this OS is linked against a libc that the tuple names.

False for Darwin and Windows-MSVC in the sense that matters here: the system C library is not a choice the user makes, so the environment field is carrying something else.

Source

pub const fn default_env(self) -> Env

The environment used when the tuple does not name one.

Windows defaults to gnu rather than msvc, and that is a decision rather than an oversight. spec/cross-compile/04-target-matrix.md puts x86_64-windows-gnu at tier 1 and x86_64-windows-msvc at tier 2 because mingw-w64 is the one we are allowed to ship, and a default that requires the user to fetch a Microsoft SDK is a default that fails on a fresh machine.

Source

pub const fn takes_version(self) -> bool

Whether an OS version in the tuple means something here.

Darwin has a deployment target that decides which declarations exist, and WASI has a preview number that decides the ABI. Everywhere else the version that matters belongs to the libc and lives in the environment version instead.

Trait Implementations§

Source§

impl Clone for Os

Source§

fn clone(&self) -> Os

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Os

Source§

impl Debug for Os

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Os

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Os

Source§

impl Hash for Os

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Os

Source§

fn cmp(&self, other: &Os) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for Os

Source§

fn eq(&self, other: &Os) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for Os

Source§

fn partial_cmp(&self, other: &Os) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for Os

Auto Trait Implementations§

§

impl Freeze for Os

§

impl RefUnwindSafe for Os

§

impl Send for Os

§

impl Sync for Os

§

impl Unpin for Os

§

impl UnsafeUnpin for Os

§

impl UnwindSafe for Os

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.