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>
impl<const WRITABLE: bool> MemoryMappedVmo<WRITABLE>
Sourcepub unsafe fn new(vmo: &Vmo) -> Result<Self, Status>
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.
Sourcepub fn vmo_size(&self) -> usize
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§impl MemoryMappedVmo<true>
impl MemoryMappedVmo<true>
Sourcepub fn get_slice_mut<'a, T: FromBytes>(
&'a mut self,
byte_offset: usize,
num_elements: usize,
) -> Result<&'a mut [T], Error>
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.
Sourcepub fn get_object_mut<'a, T: FromBytes>(
&'a mut self,
byte_offset: usize,
) -> Result<&'a mut T, Error>
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.
Sourcepub fn into_readonly(self) -> MemoryMappedVmo<false>
pub fn into_readonly(self) -> MemoryMappedVmo<false>
Downgrades a read-write mapping handle into a read-only mapping handle without unmapping.