pub struct MemoryMappedArcVmo<const WRITABLE: bool, M: Send + Sync = ()> { /* private fields */ }Expand description
Reference-counted MemoryMappedVmo backed by an auxiliary control VMO to store the reference count and, optionally, extra shared metadata.
Implementations§
Source§impl<const WRITABLE: bool, M: Send + Sync> MemoryMappedArcVmo<WRITABLE, M>
impl<const WRITABLE: bool, M: Send + Sync> MemoryMappedArcVmo<WRITABLE, M>
Sourcepub unsafe fn wrap(
storage: MemoryMappedVmo<WRITABLE>,
metadata: M,
) -> Result<Self, Status>
pub unsafe fn wrap( storage: MemoryMappedVmo<WRITABLE>, metadata: M, ) -> Result<Self, Status>
Wraps a MemoryMappedVmo into a MemoryMappedArcVmo with the given extra metadata.
§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 wrap_with_name(
storage: MemoryMappedVmo<WRITABLE>,
metadata: M,
control_vmo_name: &Name,
) -> Result<Self, Status>
pub unsafe fn wrap_with_name( storage: MemoryMappedVmo<WRITABLE>, metadata: M, control_vmo_name: &Name, ) -> Result<Self, Status>
Like wrap, but also sets the control VMO name.
§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§impl<M: Send + Sync> MemoryMappedArcVmo<true, M>
impl<M: Send + Sync> MemoryMappedArcVmo<true, M>
Sourcepub fn into_readonly(self) -> MemoryMappedArcVmo<false, M>
pub fn into_readonly(self) -> MemoryMappedArcVmo<false, M>
Downgrades a read-write mapping handle into a read-only mapping handle without unmapping.
Methods from Deref<Target = MemoryMappedVmo<WRITABLE>>§
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: FromBytes>(
&'a self,
byte_offset: usize,
num_elements: usize,
) -> Result<&'a [T], Error>
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.
Sourcepub fn get_object<'a, T: FromBytes>(
&'a self,
byte_offset: usize,
) -> Result<&'a T, Error>
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.