pub struct MemoryMappedVmo { /* private fields */ }Expand description
Memory-maps a VMO and mediates access to its memory.
Implementations§
Source§impl MemoryMappedVmo
impl MemoryMappedVmo
Sourcepub unsafe fn new_readonly(vmo: &Vmo) -> Result<MemoryMappedVmo, Status>
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.
Sourcepub unsafe fn new_readwrite(vmo: &Vmo) -> Result<MemoryMappedVmo, Status>
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.
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).
Sourcepub fn get_slice<'a, T: MemoryMappable>(
&'a self,
byte_offset: usize,
num_elements: usize,
) -> Result<&'a [T], Error>
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.
Sourcepub fn get_object<'a, T: MemoryMappable>(
&'a self,
byte_offset: usize,
) -> Result<&'a T, Error>
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.
Sourcepub fn get_slice_mut<'a, T: MemoryMappable>(
&'a mut self,
byte_offset: usize,
num_elements: usize,
) -> Result<&'a mut [T], Error>
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.
Sourcepub fn get_object_mut<'a, T: MemoryMappable>(
&'a mut self,
byte_offset: usize,
) -> Result<&'a mut T, Error>
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.