Expand description
Key: stable node identity across frames.
A key is a hash of the path from the root: each node’s key is its parent’s mixed with either a string label or a sibling index. The same logical widget therefore gets the same key every frame, retained state (focus, scroll offsets, edit buffers, tweens) is looked up by it, and a binding can reproduce a key from strings alone.
use kui_core::Key;
let list = Key::ROOT.str("list");
assert_eq!(list.index(3), Key::ROOT.str("list").index(3));
assert_ne!(list.str("3"), list.index(3)); // labels and indices never clashStructs§
- Key
- A node’s identity: the hash of its path from the root.
Key::ROOTis the tree’s root;Key::strandKey::indexderive children.
Constants§
- FNV_
OFFSET - The FNV-1a basis every hash in the core starts from — keys, the text cache’s identities, the access tree’s digest, the corpus digest.
- FNV_
PRIME
Functions§
- fnv
- FNV-1a over
bytes, continuing fromh. The one spelling of the mixer: a digest that must stay bit-stable across versions (a key, the access tree’s change detector, the corpus digest) is stable because it is this function and nothing else. A byte a round with a multiply on the chain — a nanosecond a byte — which is the right cost for a label and the wrong one for a megabyte of text: that goes throughhash_bulkfirst. - hash_
bulk - A word-wide hash of
bytes(eight a round wherefnvtakes one), for the bulk a text cache key is made of. Fx’s round (rotate, xor, multiply) with the length mixed first and murmur’s finalizer after, so a tail of zero bytes and a shorter text differ and every input bit reaches every output bit. Not a digest anything keeps across versions. - mix_
content - Mixes content into a key: short content by the byte, long content
through
hash_bulkand its eight bytes by the byte.