pub struct CNodeCap<O = Box<Cap>> {
pub slots: CNodeSlots<O>,
}Expand description
CNode cap: a sparse, direct Key -> CapHashOrRef<O> map.
rkyv (the wire form) is derived; the derive adds a slots: Archive field
bound, which for the wire payload resolves via CapHashOrRef<Box<Cap>>: Archive (gated on Box<Cap>: WireOwned, a leaf marker — no recursion into
Cap: Archive). A non-wire payload such as Box<CachedCap> does not
satisfy the field bound, so a CNodeCap<Box<CachedCap>> has no rkyv impl
and cannot cross the wire — non-serialisable by construction. Clone /
Debug / Default / HashTreeRoot are hand-rolled with payload-specific
bounds (a blanket derive would over-constrain Box<Cap>, which is not
Default, and ssz_derive::HashTreeRoot adds no bound at all, so it would
not compile for a generic field).
Fields§
§slots: CNodeSlots<O>Sparse slot table keyed by logical Key. Absent keys are empty; a
Missing(h) entry substitutes losslessly for the value rooting at h.
Implementations§
Source§impl<O> CNodeCap<O>
impl<O> CNodeCap<O>
Sourcepub fn new() -> Self
pub fn new() -> Self
Construct an empty CNode (no slots). A CNode grows on demand and is bounded by storage quota, not a fixed slot count.
Sourcepub fn commitment_key(key: &Key) -> [u8; 32]
pub fn commitment_key(key: &Key) -> [u8; 32]
Commitment radix key for a logical key: Hasher(key).
This is intentionally not used by ordinary get / set / take.
Sourcepub fn peek_key(&self, k: &[u8]) -> Option<&CapHashOrRef<O>>
pub fn peek_key(&self, k: &[u8]) -> Option<&CapHashOrRef<O>>
Borrow the cap bound to logical key k without cloning — the
read-only peek used to inspect an Owned cap (e.g. read a callee’s
image_hash to price a CALL) before deciding whether to
take_key it. None for an absent key or a
Missing(_) placeholder.
Sourcepub fn set_key(
&mut self,
k: &[u8],
target: Option<CapHashOrRef<O>>,
) -> Option<CapHashOrRef<O>>
pub fn set_key( &mut self, k: &[u8], target: Option<CapHashOrRef<O>>, ) -> Option<CapHashOrRef<O>>
Bind logical key k to target, or clear the binding if target
is None. Returns the prior materialized target, if any —
moved out, not cloned, so a CapHashOrRef::Owned(O) transfers
with no deep copy (the zero-copy cnode move).
Sourcepub fn take_key(&mut self, k: &[u8]) -> Option<CapHashOrRef<O>>
pub fn take_key(&mut self, k: &[u8]) -> Option<CapHashOrRef<O>>
Take the binding at logical key k, leaving it empty. Returns the
prior materialized target (or None), moved out — the
zero-copy half of an Owned cnode-to-cnode (or frame-to-frame)
move.
Sourcepub fn set(
&mut self,
key: &Key,
target: Option<CapHashOrRef<O>>,
) -> Result<Option<CapHashOrRef<O>>, CapError>
pub fn set( &mut self, key: &Key, target: Option<CapHashOrRef<O>>, ) -> Result<Option<CapHashOrRef<O>>, CapError>
Bind key to target, or clear it if None. Returns the prior
materialized target, if any. The radix map is unbounded, so this is
infallible; the Result is retained for ABI compatibility with the
pervasive ?-using call sites.
Source§impl<O: Clone> CNodeCap<O>
impl<O: Clone> CNodeCap<O>
Sourcepub fn get_key(&self, k: &[u8]) -> Option<CapHashOrRef<O>>
pub fn get_key(&self, k: &[u8]) -> Option<CapHashOrRef<O>>
Look up the cap bound to logical key k. Returns None for an
absent key or a Missing(_) placeholder (callers needing to tell
“absent” from “missing placeholder” apart inspect self.slots).
Sourcepub fn get(&self, key: &Key) -> Option<CapHashOrRef<O>>
pub fn get(&self, key: &Key) -> Option<CapHashOrRef<O>>
Look up the slot named by key. See CNodeCap::get_key for the
placeholder semantics.
Trait Implementations§
Source§impl<O> Archive for CNodeCap<O>where
CNodeSlots<O>: Archive,
impl<O> Archive for CNodeCap<O>where
CNodeSlots<O>: Archive,
Source§type Archived = ArchivedCNodeCap<O>
type Archived = ArchivedCNodeCap<O>
Source§type Resolver = CNodeCapResolver<O>
type Resolver = CNodeCapResolver<O>
Source§fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>)
fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>)
§const COPY_OPTIMIZATION: CopyOptimization<Self> = _
const COPY_OPTIMIZATION: CopyOptimization<Self> = _
serialize. Read moreSource§impl<__D: Fallible + ?Sized, O> Deserialize<CNodeCap<O>, __D> for Archived<CNodeCap<O>>where
CNodeSlots<O>: Archive,
<CNodeSlots<O> as Archive>::Archived: Deserialize<CNodeSlots<O>, __D>,
impl<__D: Fallible + ?Sized, O> Deserialize<CNodeCap<O>, __D> for Archived<CNodeCap<O>>where
CNodeSlots<O>: Archive,
<CNodeSlots<O> as Archive>::Archived: Deserialize<CNodeSlots<O>, __D>,
Source§impl<O> HashTreeRoot for CNodeCap<O>where
O: Clone,
CapHashOrRef<O>: HashTreeRoot,
impl<O> HashTreeRoot for CNodeCap<O>where
O: Clone,
CapHashOrRef<O>: HashTreeRoot,
Source§impl<__S: Fallible + ?Sized, O> Serialize<__S> for CNodeCap<O>where
CNodeSlots<O>: Serialize<__S>,
impl<__S: Fallible + ?Sized, O> Serialize<__S> for CNodeCap<O>where
CNodeSlots<O>: Serialize<__S>,
Auto Trait Implementations§
impl<O> Freeze for CNodeCap<O>
impl<O> RefUnwindSafe for CNodeCap<O>where
O: RefUnwindSafe,
impl<O> Send for CNodeCap<O>where
O: Send,
impl<O> Sync for CNodeCap<O>where
O: Sync,
impl<O> Unpin for CNodeCap<O>where
O: Unpin,
impl<O> UnsafeUnpin for CNodeCap<O>
impl<O> UnwindSafe for CNodeCap<O>where
O: UnwindSafe,
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive, it may be
unsized. Read more