pub struct CapabilityTable<const N: usize = DEFAULT_CAP_TABLE_CAPACITY> { /* private fields */ }Expand description
Fixed-size capability table for a partition.
Uses const generic N for the maximum number of capability slots.
No heap allocation: backed by a [CapSlot; N] array.
Implementations§
Source§impl<const N: usize> CapabilityTable<N>
impl<const N: usize> CapabilityTable<N>
Sourcepub fn insert_root(
&mut self,
token: CapToken,
owner: PartitionId,
badge: u64,
) -> CapResult<(u32, u32)>
pub fn insert_root( &mut self, token: CapToken, owner: PartitionId, badge: u64, ) -> CapResult<(u32, u32)>
Inserts a root capability. Returns (index, generation).
§Errors
Returns CapError::TableFull if no free slot is available.
Sourcepub fn insert_derived(
&mut self,
token: CapToken,
owner: PartitionId,
depth: u8,
parent_index: u32,
badge: u64,
) -> CapResult<(u32, u32)>
pub fn insert_derived( &mut self, token: CapToken, owner: PartitionId, depth: u8, parent_index: u32, badge: u64, ) -> CapResult<(u32, u32)>
Inserts a derived capability. Returns (index, generation).
§Errors
Returns CapError::TableFull if no free slot is available.
Sourcepub fn lookup(&self, index: u32, generation: u32) -> CapResult<&CapSlot>
pub fn lookup(&self, index: u32, generation: u32) -> CapResult<&CapSlot>
Looks up a slot by index and generation.
§Errors
Returns CapError::InvalidHandle if the index is out of bounds or the slot is empty.
Returns CapError::StaleHandle if the generation does not match.
Sourcepub fn lookup_mut(
&mut self,
index: u32,
generation: u32,
) -> CapResult<&mut CapSlot>
pub fn lookup_mut( &mut self, index: u32, generation: u32, ) -> CapResult<&mut CapSlot>
Looks up a slot mutably by index and generation.
§Errors
Returns CapError::InvalidHandle if the index is out of bounds or the slot is empty.
Returns CapError::StaleHandle if the generation does not match.
Sourcepub fn remove(&mut self, index: u32, generation: u32) -> CapResult<()>
pub fn remove(&mut self, index: u32, generation: u32) -> CapResult<()>
Removes a capability by index and generation.
§Errors
Returns CapError::InvalidHandle if the index is out of bounds or the slot is empty.
Returns CapError::StaleHandle if the generation does not match.