oxilean_kernel/string_intern/mod.rs
1//! Thread-safe string interning pool for `Name` construction.
2//!
3//! The kernel frequently creates `Name::Str` values from string literals.
4//! Interning them saves allocation: each unique string is stored only once,
5//! and callers receive a cheap `Copy` handle (`InternedStr`) that can be
6//! resolved back to a `&'static str` at any time.
7//!
8//! # Design
9//!
10//! - Global singleton via `std::sync::OnceLock<Arc<Mutex<InternPool>>>`.
11//! - `InternedStr` is a 32-bit index — fits in a register, implements `Copy`.
12//! - `resolve()` returns `&'static str` by leaking pool-owned strings exactly
13//! once per unique value (the leaked allocation lives for the program
14//! lifetime, matching the static lifetime contract).
15//!
16//! # Example
17//!
18//! ```
19//! use oxilean_kernel::string_intern::{intern, resolve};
20//!
21//! let h1 = intern("hello");
22//! let h2 = intern("hello");
23//! assert_eq!(h1, h2);
24//! assert_eq!(resolve(h1), "hello");
25//! ```
26
27pub mod interner;
28pub mod pool;
29
30pub use interner::{intern, resolve, InternedStr, StringInterner};
31pub use pool::InternPool;