pub enum Key {
U64(u64),
Uuid(u128),
Str(Arc<str>),
Pair(u64, u64),
}Expand description
One element’s key: what its paths, its Keyed slot, and (under persistence) its stored
row are addressed by.
A u64 key is its own path handle, with no interner, lock or allocation: exactly the cost
integer keys always had. The wide forms (Uuid, Str, Pair) intern process-globally to
a u64 handle on first use, so paths stay 12 bytes and every collection index stays
u64-keyed. A handle, once minted, is stable for the process’s lifetime (undo records
and long-lived ModelIds rely on that) and reverses through Key::of_handle; the
interner’s size is observable via interned_keys.
Variants§
U64(u64)
Uuid(u128)
A UUID, carried as its raw 128 bits (uuid::Uuid::as_u128).
Str(Arc<str>)
A natural string key: a slug, an external system’s id.
Pair(u64, u64)
Two handles as one key: how the persistence layer addresses join rows. Apps rarely construct one directly.
Implementations§
Source§impl Key
impl Key
Sourcepub fn handle(&self) -> u64
pub fn handle(&self) -> u64
The key’s path handle: identity for U64, interned (once, then a read-locked lookup)
for the wide forms. Callable from any thread; the interner is process-global.
Sourcepub fn of_handle(handle: u64) -> Option<Key>
pub fn of_handle(handle: u64) -> Option<Key>
The key a handle names: identity below the wide floor, the interner’s record above
it. None only for a wide handle nothing ever interned (a forged value).