Skip to main content

Module slot

Module slot 

Source
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§

ArchivedKey
An archived Key
ArchivedSlotPath
An archived SlotPath
Key
The logical key naming one slot in a single cnode.
KeyResolver
The resolver for an archived Key
SlotPath
Path from the root cnode through nested cnodes to a slot.
SlotPathResolver
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 Key from the (packed, len) register pair produced by key_to_regs. A len > 8 is clamped to 8 (defensive; key_to_regs never emits one).
key_to_regs
Pack a Key (≤ MAX_KEY_LEN bytes) 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 of key_from_regs.