Skip to main content

MemoryMappedVmo

Struct MemoryMappedVmo 

Source
pub struct MemoryMappedVmo<const WRITABLE: bool> { /* private fields */ }
Expand description

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

Implementations§

Source§

impl<const WRITABLE: bool> MemoryMappedVmo<WRITABLE>

Source

pub unsafe fn new(vmo: &Vmo) -> Result<Self, Status>

Maps a VMO into memory (read-only if WRITABLE is false, read-write if WRITABLE is true).

§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: FromBytes>( &'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: FromBytes>( &'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§

impl MemoryMappedVmo<true>

Source

pub fn get_slice_mut<'a, T: FromBytes>( &'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: FromBytes>( &'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.

Source

pub fn into_readonly(self) -> MemoryMappedVmo<false>

Downgrades a read-write mapping handle into a read-only mapping handle without unmapping.

Trait Implementations§

Source§

impl Deref for MemoryMappedVmo<true>

Source§

type Target = MemoryMappedVmo<false>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<const WRITABLE: bool> Drop for MemoryMappedVmo<WRITABLE>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

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<const WRITABLE: bool> Freeze for MemoryMappedVmo<WRITABLE>

§

impl<const WRITABLE: bool> RefUnwindSafe for MemoryMappedVmo<WRITABLE>

§

impl<const WRITABLE: bool> Send for MemoryMappedVmo<WRITABLE>

§

impl<const WRITABLE: bool> Sync for MemoryMappedVmo<WRITABLE>

§

impl<const WRITABLE: bool> Unpin for MemoryMappedVmo<WRITABLE>

§

impl<const WRITABLE: bool> UnsafeUnpin for MemoryMappedVmo<WRITABLE>

§

impl<const WRITABLE: bool> UnwindSafe for MemoryMappedVmo<WRITABLE>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.