Skip to main content

CapSlot

Struct CapSlot 

Source
pub struct CapSlot {
    pub token: CapToken,
    pub generation: u32,
    pub owner: PartitionId,
    pub depth: u8,
    pub parent_index: u32,
    pub badge: u64,
}
Expand description

A slot in the capability table.

Each slot holds either a valid capability or is marked as free for reuse. Generation counters prevent stale handle access after deallocation.

Fields§

§token: CapToken

The capability token (valid when generation != 0).

§generation: u32

Generation counter for stale handle detection.

Generation 0 is the invalid sentinel: a slot with generation == 0 is empty/free. Live slots always have generation >= 1, and the counter skips 0 on wrap-around (see invalidate).

§Security note

This is a u32, giving a 2^32 cycle forgery window: if an attacker can cause exactly 2^32 allocate/free cycles on a single slot, a stale handle could alias a new capability. In practice this is infeasible (would require ~4 billion operations on one slot), and widening to u64 would double CapSlot size and break the memory layout. Accepted as a low-severity residual risk.

§owner: PartitionId

The partition that owns this capability.

§depth: u8

Delegation depth (0 = root capability).

§parent_index: u32

Parent slot index (u32::MAX if root).

§badge: u64

Badge value for identifying the granting chain.

Implementations§

Source§

impl CapSlot

Source

pub const fn is_valid(&self) -> bool

Returns true if this slot is currently valid (in use).

Source

pub const fn matches(&self, generation: u32) -> bool

Returns true if this slot matches the given generation.

Source

pub fn invalidate(&mut self)

Invalidates this slot, bumping the generation counter for the next allocation and then clearing it to 0 (the free sentinel).

The bumped generation is stored in parent_index (unused while the slot is free) so that the next insert_* call can recover it.

§Security

Generation 0 is the invalid sentinel. The counter skips 0 on wrap-around so that a re-allocated slot never gets generation 0.

Trait Implementations§

Source§

impl Clone for CapSlot

Source§

fn clone(&self) -> CapSlot

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for CapSlot

Source§

impl Debug for CapSlot

Source§

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

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

impl Eq for CapSlot

Source§

impl PartialEq for CapSlot

Source§

fn eq(&self, other: &CapSlot) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CapSlot

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.