Skip to main content

CapabilityTable

Struct CapabilityTable 

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

Source

pub const fn new() -> Self

Creates a new empty capability table.

Source

pub const fn capacity(&self) -> usize

Returns the table capacity.

Source

pub const fn len(&self) -> usize

Returns the number of valid entries.

Source

pub const fn is_empty(&self) -> bool

Returns true if the table has no valid entries.

Source

pub const fn is_full(&self) -> bool

Returns true if the table is full.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn iter(&self) -> impl Iterator<Item = (u32, &CapSlot)>

Returns an iterator over all valid entries as (index, &CapSlot).

Trait Implementations§

Source§

impl<const N: usize> Debug for CapabilityTable<N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const N: usize> Default for CapabilityTable<N>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<const N: usize> Freeze for CapabilityTable<N>
where [CapSlot; N]: Freeze,

§

impl<const N: usize> RefUnwindSafe for CapabilityTable<N>

§

impl<const N: usize> Send for CapabilityTable<N>
where [CapSlot; N]: Send,

§

impl<const N: usize> Sync for CapabilityTable<N>
where [CapSlot; N]: Sync,

§

impl<const N: usize> Unpin for CapabilityTable<N>
where [CapSlot; N]: Unpin,

§

impl<const N: usize> UnsafeUnpin for CapabilityTable<N>
where [CapSlot; N]: UnsafeUnpin,

§

impl<const N: usize> UnwindSafe for CapabilityTable<N>
where [CapSlot; N]: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.