Skip to main content

HandleTable

Struct HandleTable 

Source
pub struct HandleTable {
    slots: Vec<Slot>,
    free: Vec<u32>,
    len: usize,
    reserved: usize,
}
Expand description

The process handle table.

Index 0 is permanently reserved and never handed out: this makes handle value 0 (structure (index=0, gen=0)/2) impossible without needing a non-zero starting generation. A new slot starts at generation 1 and every reuse increments the generation before the entry becomes visible.

Fields§

§slots: Vec<Slot>§free: Vec<u32>§len: usize§reserved: usize

Slots promised to an in-progress receive (§4.5 step 3). Counted against HandleTable::free_slots but not yet occupied; HandleTable::insert consumes one unit per successful insert.

Implementations§

Source§

impl HandleTable

Source

pub fn new() -> Self

Create an empty table with the reserved index-0 slot.

Source

pub fn table_len(&self) -> usize

Number of live entries.

Source

pub fn reserved(&self) -> usize

Number of slots currently promised by HandleTable::reserve.

Source

pub fn free_slots(&self) -> usize

Slots that may still be handed out, honouring outstanding reservations.

Source

pub fn reserve(&mut self, n: usize) -> Result<(), SyscallError>

Reserve n slots for an in-progress receive (§4.5 step 3).

Invariant: after a successful reserve(n) the next n successful HandleTable::insert calls cannot fail for capacity reasons; each one consumes one reserved unit. The caller must release any unused units with HandleTable::release_reservation.

Source

pub fn release_reservation(&mut self, n: usize)

Return n unused reserved slots (saturating).

Source

pub fn insert(&mut self, rights: u32, obj: ObjRef, badge: u64) -> Option<Handle>

Insert an entry, reusing a free slot if possible.

Returns None when the table already holds MAX_HANDLES entries and no reservation covers this insert. A successful insert consumes one unit of an outstanding reservation, guaranteeing it cannot fail.

Source

pub fn resolve(&self, h: Handle, required: u32) -> Result<Entry, SyscallError>

Resolve a handle and check that required rights are present.

Source

pub fn remove(&mut self, h: Handle) -> Result<Entry, SyscallError>

Take an entry out of the table and apply its object side effects (endpoint reference release, Reply-handle cancellation).

Source

pub fn remove_raw(&mut self, h: Handle) -> Result<Entry, SyscallError>

Take an entry out of the table without object side effects.

For consumption paths that take over the object’s obligations, e.g. sys_ep_reply, which delivers the reply immediately afterwards and must not cancel the call it is completing.

Source

pub fn remove_all(&mut self)

Drain every entry, applying the object-side effects of dropping each handle (in particular closing the last EP_RECV endpoint reference).

Source

pub fn duplicate( &mut self, h: Handle, requested_rights: u32, ) -> Result<Handle, SyscallError>

Duplicate a handle with an equal or smaller rights mask.

Source

pub fn fork_clone(&self) -> Self

Clone this table for fork: same objects, rights and generations. Every copied EP_RECV endpoint entry takes an extra reference.

Source

pub const fn generic_rights() -> u32

Mask of rights that may be requested through ipc_mint/duplicate.

Source

fn validate(&self, h: Handle) -> Result<Entry, SyscallError>

Trait Implementations§

Source§

impl Default for HandleTable

Source§

fn default() -> Self

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

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.