Enum platform_lp::Platform
source · pub enum Platform {
Win64,
Win32,
Nix64,
Nix32,
Mac64,
Mac32,
None,
}
Variants
Win64
Win32
Nix64
Nix32
Mac64
Mac32
None
Implementations
sourceimpl Platform
impl Platform
sourcepub fn new(platform: &str) -> Platform
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)
sourcepub fn as_str(&self) -> &'static str
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’
sourcepub fn to_short_string(&self) -> String
pub fn to_short_string(&self) -> String
returns a String object with the short &str value of the platform
sourcepub fn as_short_str(&self) -> &'static str
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’
sourcepub fn is_valid_execution_platform(&self) -> bool
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 (==).
sourcepub fn is_compatible(&self, other: &Platform) -> bool
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.
sourcepub fn get_user_platform() -> Platform
pub fn get_user_platform() -> Platform
Returns the current user platform
sourcepub fn get_valid_execution_platform() -> Vec<Platform>
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.