MemoryMappedVmo

Struct MemoryMappedVmo 

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

Memory-maps a VMO and mediates access to its memory.

Implementations§

Source§

impl MemoryMappedVmo

Source

pub unsafe fn new_readonly(vmo: &Vmo) -> Result<MemoryMappedVmo, Status>

Maps a VMO in read-only mode.

Attempting to call methods on the returned object that return mutable references will panic.

§Safety

The caller must either guarantee that the vmo is not modified by others while the returned instance is alive or that accesses are synchronized in application-specific ways.

Source

pub unsafe fn new_readwrite(vmo: &Vmo) -> Result<MemoryMappedVmo, Status>

Maps a VMO in read-write mode.

§Safety

The caller must either guarantee that the vmo is not modified by others while the returned instance is alive or that accesses are synchronized in application-specific ways.

Source

pub fn vmo_size(&self) -> usize

Returns the number of usable bytes in the VMO (i.e. its ZX_PROP_VMO_CONTENT_SIZE property, which is not rounded to the page size).

Source

pub fn get_slice<'a, T: MemoryMappable>( &'a self, byte_offset: usize, num_elements: usize, ) -> Result<&'a [T], Error>

Returns a reference to a slice of elements in the VMO.

This method validates the alignment and the bounds against the VMO size.

Source

pub fn get_object<'a, T: MemoryMappable>( &'a self, byte_offset: usize, ) -> Result<&'a T, Error>

Returns a reference to an element in the VMO.

This method validates the alignment and the bounds against the VMO size.

Source

pub fn get_slice_mut<'a, T: MemoryMappable>( &'a mut self, byte_offset: usize, num_elements: usize, ) -> Result<&'a mut [T], Error>

Returns a mutable reference to a slice of elements in the VMO.

This method validates the alignment and the bounds against the VMO size.

Source

pub fn get_object_mut<'a, T: MemoryMappable>( &'a mut self, byte_offset: usize, ) -> Result<&'a mut T, Error>

Returns a mutable reference to an element in the VMO.

This method validates the alignment and the bounds against the VMO size.

Trait Implementations§

Source§

impl Drop for MemoryMappedVmo

Source§

fn drop(&mut self)

Executes the destructor for this 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
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.