gentoo_core/lib.rs
1//! Core Gentoo types and utilities
2//!
3//! This crate provides efficient types for working with Gentoo architecture
4//! keywords and release media variants. It is designed for use in tools that
5//! process large numbers of ebuilds or repository metadata, where string
6//! deduplication provides measurable memory savings.
7//!
8//! # Architecture Handling
9//!
10//! [`Arch`] represents a CPU architecture, mapping to the corresponding Gentoo
11//! keyword when the architecture is known (e.g., `"amd64"`, `"arm64"`). Unknown
12//! or overlay-specific architectures are stored as opaque strings.
13//!
14//! [`KnownArch`] enumerates the 18 architectures officially supported by Gentoo,
15//! providing zero-cost representation and additional metadata like bitness.
16//!
17//! # Release Media Variants
18//!
19//! [`Variant`] represents the `{arch}-{tag}` format used for Gentoo release
20//! media (stage3 tarballs, ISO images). The tag typically encodes the init
21//! system and profile (e.g., `"amd64-openrc"`, `"arm64-systemd"`).
22//!
23//! # Interning
24//!
25//! Both `Arch` and `Variant` use string interning to reduce memory usage when
26//! processing many instances (e.g., parsing an entire ebuild repository).
27//! With the default `interner` feature, identical strings share a single
28//! allocation via a process-global interners.
29
30pub mod arch;
31mod error;
32pub mod interner {
33 //! String interning for efficient string storage.
34 pub use gentoo_interner::*;
35}
36pub mod variant;
37
38pub use error::Error;
39
40pub use arch::KnownArch;
41
42/// A Gentoo architecture, either well-known or overlay-defined.
43pub type Arch = arch::Arch<interner::DefaultInterner>;
44
45/// A Gentoo release media variant (e.g., `amd64-openrc`, `arm64-systemd`).
46pub type Variant = variant::Variant<interner::DefaultInterner>;
47
48#[cfg(test)]
49mod tests {
50 use super::*;
51
52 #[test]
53 fn arch_alias() {
54 let a = Arch::from_chost("aarch64").unwrap();
55
56 println!("{a:?}");
57 }
58}