#[non_exhaustive]pub enum Arch {
Show 13 variants
X86,
X86_64,
AARCH64,
ARM,
RISCV32,
RISCV64,
WASM32,
WASM64,
MIPS,
MIPS64,
POWERPC,
POWERPC64,
S390X,
}sys only.Expand description
CPU architecture type.
This enum provides type-safe CPU architecture identifiers. All variants are validated at construction time.
§Invariants
- All variants represent valid CPU architectures
- Architecture information is determined at compile time
§Examples
use bare_types::sys::Arch;
// Use predefined constants
let arch = Arch::X86_64;
assert!(arch.is_64_bit());
// Get current architecture
let current = Arch::current();
println!("Running on: {}", current);
// Convert to string representation
assert_eq!(Arch::AARCH64.as_str(), "aarch64");Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
X86
32-bit x86 architecture (i386, i686)
X86_64
64-bit x86 architecture (amd64)
AARCH64
64-bit ARM architecture (arm64)
ARM
32-bit ARM architecture
RISCV32
32-bit RISC-V architecture
RISCV64
64-bit RISC-V architecture
WASM32
32-bit WebAssembly
WASM64
64-bit WebAssembly
MIPS
32-bit MIPS architecture
MIPS64
64-bit MIPS architecture
POWERPC
32-bit PowerPC architecture
POWERPC64
64-bit PowerPC architecture
S390X
IBM System/390 architecture
Implementations§
Source§impl Arch
impl Arch
Sourcepub const fn current() -> Self
pub const fn current() -> Self
Returns the current architecture (compile-time constant).
This method returns the architecture the code was compiled for, not necessarily the architecture of the host system (especially relevant for cross-compilation).
§Examples
use bare_types::sys::Arch;
let arch = Arch::current();
println!("Compiled for: {}", arch);Sourcepub const fn as_str(&self) -> &'static str
pub const fn as_str(&self) -> &'static str
Returns the string representation of this architecture.
§Examples
use bare_types::sys::Arch;
assert_eq!(Arch::X86_64.as_str(), "x86_64");
assert_eq!(Arch::AARCH64.as_str(), "aarch64");
assert_eq!(Arch::X86.as_str(), "x86");Sourcepub const fn is_64_bit(&self) -> bool
pub const fn is_64_bit(&self) -> bool
Returns true if this is a 64-bit architecture.
§Examples
use bare_types::sys::Arch;
assert!(Arch::X86_64.is_64_bit());
assert!(Arch::AARCH64.is_64_bit());
assert!(!Arch::X86.is_64_bit());
assert!(!Arch::ARM.is_64_bit());Sourcepub const fn is_32_bit(&self) -> bool
pub const fn is_32_bit(&self) -> bool
Returns true if this is a 32-bit architecture.
§Examples
use bare_types::sys::Arch;
assert!(Arch::X86.is_32_bit());
assert!(Arch::ARM.is_32_bit());
assert!(!Arch::X86_64.is_32_bit());
assert!(!Arch::AARCH64.is_32_bit());Sourcepub const fn is_arm(&self) -> bool
pub const fn is_arm(&self) -> bool
Returns true if this is an ARM architecture.
§Examples
use bare_types::sys::Arch;
assert!(Arch::AARCH64.is_arm());
assert!(Arch::ARM.is_arm());
assert!(!Arch::X86_64.is_arm());Sourcepub const fn is_x86(&self) -> bool
pub const fn is_x86(&self) -> bool
Returns true if this is an x86 architecture.
§Examples
use bare_types::sys::Arch;
assert!(Arch::X86.is_x86());
assert!(Arch::X86_64.is_x86());
assert!(!Arch::AARCH64.is_x86());Sourcepub const fn is_riscv(&self) -> bool
pub const fn is_riscv(&self) -> bool
Returns true if this is a RISC-V architecture.
§Examples
use bare_types::sys::Arch;
assert!(Arch::RISCV32.is_riscv());
assert!(Arch::RISCV64.is_riscv());
assert!(!Arch::X86_64.is_riscv());Sourcepub const fn is_wasm(&self) -> bool
pub const fn is_wasm(&self) -> bool
Returns true if this is a WebAssembly architecture.
§Examples
use bare_types::sys::Arch;
assert!(Arch::WASM32.is_wasm());
assert!(Arch::WASM64.is_wasm());
assert!(!Arch::X86_64.is_wasm());Sourcepub const fn is_mips(&self) -> bool
pub const fn is_mips(&self) -> bool
Returns true if this is a MIPS architecture.
§Examples
use bare_types::sys::Arch;
assert!(Arch::MIPS.is_mips());
assert!(Arch::MIPS64.is_mips());
assert!(!Arch::X86_64.is_mips());Sourcepub const fn is_powerpc(&self) -> bool
pub const fn is_powerpc(&self) -> bool
Returns true if this is a PowerPC architecture.
§Examples
use bare_types::sys::Arch;
assert!(Arch::POWERPC.is_powerpc());
assert!(Arch::POWERPC64.is_powerpc());
assert!(!Arch::X86_64.is_powerpc());Sourcepub const fn pointer_width(&self) -> u8
pub const fn pointer_width(&self) -> u8
Returns the pointer width in bits for this architecture.
§Examples
use bare_types::sys::Arch;
assert_eq!(Arch::X86_64.pointer_width(), 64);
assert_eq!(Arch::X86.pointer_width(), 32);
assert_eq!(Arch::AARCH64.pointer_width(), 64);Trait Implementations§
Source§impl<'arbitrary> Arbitrary<'arbitrary> for Arch
impl<'arbitrary> Arbitrary<'arbitrary> for Arch
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