pub enum Arch<I = DefaultInterner>where
I: Interner,{
Known(KnownArch),
Exotic(ExoticKey<I>),
}Expand description
A Gentoo architecture keyword.
Represents either a well-known Gentoo architecture or an overlay-specific
keyword string. This type is used when parsing ebuild KEYWORDS or other
architecture references that may include non-standard values.
§Variants
Known(KnownArch): A recognized Gentoo architecture. Zero-cost andCopy.Exotic(ExoticKey<I>): An overlay-defined keyword stored via interning.
§Memory Efficiency
With the default interner feature, Arch<GlobalInterner> is Copy (4 bytes)
and identical exotic strings share a single allocation. This is useful when
processing large numbers of ebuilds.
§Examples
use gentoo_core::Arch;
// Known architectures are recognized automatically
let known = Arch::intern("amd64");
assert_eq!(known.as_str(), "amd64");
// Unknown strings become exotic keys
let exotic = Arch::intern("my-custom-board");
assert_eq!(exotic.as_str(), "my-custom-board");Variants§
Known(KnownArch)
A well-known Gentoo architecture keyword.
Exotic(ExoticKey<I>)
An overlay-defined keyword string interned via I.
Implementations§
Source§impl<I: Interner> Arch<I>
impl<I: Interner> Arch<I>
Sourcepub fn current() -> Self
pub fn current() -> Self
Current system architecture from std::env::consts::ARCH.
Returns Known for recognized architectures, Exotic otherwise.
Sourcepub fn from_chost(chost: &str) -> Option<Self>
pub fn from_chost(chost: &str) -> Option<Self>
Extract the CPU arch from a GNU CHOST triple using the interner I.
Returns None only when chost is empty.
Sourcepub fn as_keyword(&self) -> &str
pub fn as_keyword(&self) -> &str
The Gentoo keyword for this architecture.
For known architectures, returns the canonical keyword (e.g., "amd64").
For exotic architectures, returns the interned string directly.