pub struct CNodeCap {
pub size_log: u8,
pub slots: SparseList<CapHashOrRef, MAX_CNODE_SLOTS>,
}Fields§
§size_log: u8§slots: SparseList<CapHashOrRef, MAX_CNODE_SLOTS>Sparse slot table keyed by slot index. Missing keys are absent
slots (contribute zero_hash to the merkle root). The merkle
tree is always size MAX_CNODE_SLOTS = 2^16; size_log bounds
the addressable range.
Implementations§
Source§impl CNodeCap
impl CNodeCap
Sourcepub fn new(size_log: u8) -> Result<Self, CapError>
pub fn new(size_log: u8) -> Result<Self, CapError>
Construct an empty cnode of 2^size_log slots.
Rejects size_log > 16.
Sourcepub fn get(&self, slot: SlotIdx) -> Option<CapHashOrRef>
pub fn get(&self, slot: SlotIdx) -> Option<CapHashOrRef>
Look up a slot by index. Returns None for empty (unmaterialized)
slots; returns the materialized CapHashOrRef otherwise.
For a MissingOr::Missing(_) placeholder slot (used when a
subtree was loaded by hash without contents), this returns
None — callers needing to distinguish “absent” from “missing
placeholder” should inspect self.slots.get(...) directly.
Sourcepub fn set(
&mut self,
slot: SlotIdx,
target: Option<CapHashOrRef>,
) -> Result<Option<CapHashOrRef>, CapError>
pub fn set( &mut self, slot: SlotIdx, target: Option<CapHashOrRef>, ) -> Result<Option<CapHashOrRef>, CapError>
Bind slot to target, or clear the binding if target is
None. Rejects slot indices outside the cnode’s 2^size_log
range. Returns the prior materialized target at slot, if any.