Enum Platform

Source
pub enum Platform {
    Win64,
    Win32,
    Nix64,
    Nix32,
    Mac64,
    Mac32,
    None,
}
Expand description

Platform struct, designed to completely describe the current platform or other possible platforms.

Variants§

§

Win64

§

Win32

§

Nix64

§

Nix32

§

Mac64

§

Mac32

§

None

Implementations§

Source§

impl Platform

Source

pub fn new(platform: &str) -> Platform

Creates a new platform from a string.

Works through a number of different possibilities to make sure the correct platform is matched based on the string entered.

Supports exact matches to the enums as_str and as_short_str as well as pattern matching with keywords such as:

  • 64,32
  • win,nix,linux,mac
  • lxx,wxx,mxx (for short codes)
Source

pub fn clone(&self) -> Platform

Creates a copy of the enum object.

Source

pub fn display(&self) -> &'static str

Displays the platform object using as_str

Source

pub fn to_string(&self) -> String

returns a String object with the &str value of the platform

Source

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

Returns a &str constant value for each type.

  • Win64 === ‘Windows x86_64’
  • Win32 === ‘Windows x32’
  • Nix64 === ‘Linux x86_64’
  • Nix32 === ‘Linux x32’
  • Mac64 === ‘Mac OS x86_64’
  • Mac32 === ‘Mac OS x32’
  • None === ‘None’
Source

pub fn to_short_string(&self) -> String

returns a String object with the short &str value of the platform

Source

pub fn as_short_str(&self) -> &'static str

Returns a short &str constant value

  • Win64 === ‘win64’
  • Win32 === ‘win32’
  • Nix64 === ‘nix64’
  • Nix32 === ‘nix32’
  • Mac64 === ‘mac64’
  • Mac32 === ‘mac32’
  • None === ‘None’
Source

pub fn is_valid_execution_platform(&self) -> bool

Checks if a a binary were built for the self platform could be executed on the current user platform.

Assumes that 32 bit applications can be executed on 64 bit platforms. If you don’t want to assume this then don’t use this funtion and instead check absolute equality (==).

Source

pub fn is_compatible(&self, other: &Platform) -> bool

Checks if this platform is compatible with the other platform,

Works on the assumption that 32 bit is compatible with 64 bit.

Source

pub fn get_user_platform() -> Platform

Returns the current user platform

Source

pub fn get_valid_execution_platform() -> Vec<Platform>

Returns a Vec of all the available execution platforms

Typically its a vector of 1, but also returns the 32bit version on 64bit systems.

Source

pub fn iterator() -> Iter<'static, Platform>

An iterator that iterates through all the defined platforms

Trait Implementations§

Source§

impl Debug for Platform

Source§

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

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

impl<'de> Deserialize<'de> for Platform

Source§

fn deserialize<D>(deserializer: D) -> Result<Platform, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Platform

Source§

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

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

impl Hash for Platform

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 PartialEq<Architecture> for Platform

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<PartialPlatform> for Platform

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Platform> for Architecture

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Platform> for PartialPlatform

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for Platform

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Platform

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Platform

Source§

impl StructuralPartialEq for Platform

Auto Trait Implementations§

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> 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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,