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 ProcessGrant
s, which are tied to a specific
process and provide access to the memory object allocated for that process.
Implementations
sourceimpl<T: Default, Upcalls: UpcallSize, AllowROs: AllowRoSize, AllowRWs: AllowRwSize> Grant<T, Upcalls, AllowROs, AllowRWs>
impl<T: Default, Upcalls: UpcallSize, AllowROs: AllowRoSize, AllowRWs: AllowRwSize> Grant<T, Upcalls, AllowROs, AllowRWs>
sourcepub fn enter<F, R>(&self, processid: ProcessId, fun: F) -> Result<R, Error> where
F: FnOnce(&mut GrantData<'_, T>, &GrantKernelData<'_>) -> R,
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.
sourcepub fn enter_with_allocator<F, R>(
&self,
processid: ProcessId,
fun: F
) -> Result<R, Error> where
F: FnOnce(&mut GrantData<'_, T>, &GrantKernelData<'_>, &mut GrantRegionAllocator) -> R,
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.
sourcepub fn each<F>(&self, fun: F) where
F: FnMut(ProcessId, &mut GrantData<'_, T>, &GrantKernelData<'_>),
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.
sourcepub fn iter(&self) -> Iter<'_, T, Upcalls, AllowROs, AllowRWs>ⓘNotable traits for Iter<'a, T, Upcalls, AllowROs, AllowRWs>impl<'a, T: Default, Upcalls: UpcallSize, AllowROs: AllowRoSize, AllowRWs: AllowRwSize> Iterator for Iter<'a, T, Upcalls, AllowROs, AllowRWs> type Item = ProcessGrant<'a, T, Upcalls, AllowROs, AllowRWs>;
pub fn iter(&self) -> Iter<'_, T, Upcalls, AllowROs, AllowRWs>ⓘNotable traits for Iter<'a, T, Upcalls, AllowROs, AllowRWs>impl<'a, T: Default, Upcalls: UpcallSize, AllowROs: AllowRoSize, AllowRWs: AllowRwSize> Iterator for Iter<'a, T, Upcalls, AllowROs, AllowRWs> type Item = ProcessGrant<'a, 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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more