Skip to main content

UserMemory

Struct UserMemory 

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

UserMemory facilitates testing code that requires user memory.

Example: let mut mem = UserMemory::create(size).unwrap(); mem.commit_and_map(size).unwrap(); let out_ptr = UserOutPtr::::new(mem.base() as *mut u32); out_ptr.write(value).unwrap();

Implementations§

Source§

impl UserMemory

Source

pub fn create(size: usize) -> Option<Self>

Source

pub fn base(&self) -> usize

Source

pub fn commit_and_map(&mut self, size: usize) -> Result<(), Status>

Ensures the mapping is committed and mapped such that usages will cause no faults.

Source

pub fn vmo_write(&mut self, data: &[u8], offset: u64) -> Result<(), Status>

Write to the underlying VMO directly, bypassing the mapping.

Source

pub fn vmo_read(&mut self, data: &mut [u8], offset: u64) -> Result<(), Status>

Read from the underlying VMO directly, bypassing the mapping.

Trait Implementations§

Source§

impl Drop for UserMemory

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for UserMemory

§

impl !Send for UserMemory

§

impl !Sync for UserMemory

§

impl !UnwindSafe for UserMemory

§

impl Freeze for UserMemory

§

impl Unpin for UserMemory

§

impl UnsafeUnpin for UserMemory

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

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> ToMutPtr for T
where T: ?Sized,

Source§

type Target = T

The target type of the pointer.
Source§

fn to_mut_ptr(&self) -> *mut T

Casts the reference to a mutable raw pointer.
§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.