Skip to main content

Region

Struct Region 

Source
pub struct Region { /* private fields */ }
Expand description

A run of pages AllocMem mapped for this task, readable and writable, owned by this value.

Neither Clone nor Copy: there is one owner, and a mutable slice can be borrowed from it only through &mut self, so no two live slices of it can alias.

Implementations§

Source§

impl Region

Source

pub fn alloc(ctx: &ServiceContext, bytes: usize) -> Result<Region, AllocError>

Ask the kernel for at least bytes of fresh memory, rounded up to whole pages.

Denied when it would pass this task’s memory limit, Failed when the machine has no frames left or bytes is zero or too large to round.

Source

pub fn len(&self) -> usize

Its length in bytes: a whole number of pages, at least what was asked for.

Source

pub fn is_empty(&self) -> bool

Always false: a region of no bytes cannot be made.

Source

pub fn bytes(&self) -> &[u8]

The region, to read.

Source

pub fn bytes_mut(&mut self) -> &mut [u8]

The region, to write.

Source

pub fn words_mut(&mut self) -> &mut [u32]

The region as 32-bit words, to write: for a device FIFO that is read a word at a time (a WiFi chip’s SDIO read buffer, larger than any stack can hold). The same memory as bytes, in the machine’s own byte order.

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