Struct kernel::grant::Grant

source ·
pub struct Grant<T: Default, Upcalls: UpcallSize, AllowROs: AllowRoSize, AllowRWs: AllowRwSize> { /* private fields */ }
Expand description

Type for storing an object of type T in process memory that is only accessible by the kernel.

A single Grant can allocate space for one object of type T for each process on the board. Each allocated object will reside in the grant region belonging to the process that the object is allocated for. The Grant type is used to get access to ProcessGrants, which are tied to a specific process and provide access to the memory object allocated for that process.

Implementations§

source§

impl<T: Default, Upcalls: UpcallSize, AllowROs: AllowRoSize, AllowRWs: AllowRwSize> Grant<T, Upcalls, AllowROs, AllowRWs>

source

pub fn enter<F, R>(&self, processid: ProcessId, fun: F) -> Result<R, Error>
where F: FnOnce(&mut GrantData<'_, T>, &GrantKernelData<'_>) -> R,

Enter the grant for a specific process.

This creates a ProcessGrant which is a handle for a grant allocated for a specific process. Then, that ProcessGrant is entered and the provided closure is run with access to the memory in the grant region.

source

pub fn enter_with_allocator<F, R>( &self, processid: ProcessId, fun: F ) -> Result<R, Error>
where F: FnOnce(&mut GrantData<'_, T>, &GrantKernelData<'_>, &mut GrantRegionAllocator) -> R,

Enter the grant for a specific process with access to an allocator.

This creates an ProcessGrant which is a handle for a grant allocated for a specific process. Then, that ProcessGrant is entered and the provided closure is run with access to the memory in the grant region.

The allocator allows the caller to dynamically allocate additional memory in the process’s grant region.

source

pub fn each<F>(&self, fun: F)
where F: FnMut(ProcessId, &mut GrantData<'_, T>, &GrantKernelData<'_>),

Run a function on the grant for each active process if the grant has been allocated for that process.

This will silently skip any process where the grant has not previously been allocated. This will also silently skip any invalid processes.

Calling this function when an ProcessGrant for a process is currently entered will result in a panic.

source

pub fn iter(&self) -> Iter<'_, T, Upcalls, AllowROs, AllowRWs>

Get an iterator over all processes and their active grant regions for this particular grant.

Calling this function when an ProcessGrant for a process is currently entered will result in a panic.

Auto Trait Implementations§

§

impl<T, Upcalls, AllowROs, AllowRWs> !RefUnwindSafe for Grant<T, Upcalls, AllowROs, AllowRWs>

§

impl<T, Upcalls, AllowROs, AllowRWs> !Send for Grant<T, Upcalls, AllowROs, AllowRWs>

§

impl<T, Upcalls, AllowROs, AllowRWs> !Sync for Grant<T, Upcalls, AllowROs, AllowRWs>

§

impl<T, Upcalls, AllowROs, AllowRWs> Unpin for Grant<T, Upcalls, AllowROs, AllowRWs>
where AllowROs: Unpin, AllowRWs: Unpin, T: Unpin, Upcalls: Unpin,

§

impl<T, Upcalls, AllowROs, AllowRWs> !UnwindSafe for Grant<T, Upcalls, AllowROs, AllowRWs>

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

source§

const IS_ZST: bool = _

🔬This is a nightly-only experimental API. (sized_type_properties)
true if this type requires no storage. false if its size is greater than zero. Read more
source§

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

§

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

§

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.