Expand description
Byte-string keys and slot addressing.
Key is the byte-string key type used across the cap model: it names
one slot in a single cnode (a slot key), and it also keys the kernel’s
resource tables (a meter key / quota key — same type, unrelated meaning;
see the kernel-assisted Gas/Quota handles). A SlotPath walks from the
root cnode through nested Cap::CNode slots down to a target slot.
A cnode is a sparse direct map keyed by logical byte strings, not an
integer-indexed array — so a slot name is a Key (a short byte string),
and a path is a SlotPath (a sequence of Keys). There is no fixed slot
count: a cnode is bounded by storage quota, not a compile-time capacity.
The V1 ABI uses single-byte keys (Key::from(b)), but the type admits
arbitrary-length keys for future ABI extensions (e.g.
address -> Cap::Instance).
Structs§
- Archived
Key - An archived
Key - Archived
Slot Path - An archived
SlotPath - Key
- The logical key naming one slot in a single cnode.
- KeyResolver
- The resolver for an archived
Key - Slot
Path - Path from the root cnode through nested cnodes to a slot.
- Slot
Path Resolver - The resolver for an archived
SlotPath
Constants§
- MAX_
KEY_ LEN - Inline byte capacity of a
Key. Keys longer than this spill to the heap — there is no hard cap (unlike a fixed array). The V1 ABI uses 1-byte keys; 8 bytes inline covers an address-sized key without allocating.
Functions§
- key_
from_ regs - Reconstruct a
Keyfrom the(packed, len)register pair produced bykey_to_regs. Alen > 8is clamped to 8 (defensive;key_to_regsnever emits one). - key_
to_ regs - Pack a
Key(≤MAX_KEY_LENbytes) into two registers for storage in a kernel-assisted unit handle (Gas{meter_key}/Quota{quota_key}): the key bytes little-endian-packed into the first register, the byte length into the second. Inverse ofkey_from_regs.