pub enum MemoryObject {
Vmo(VmoAndBasicInfo),
RingBuf(VmoAndBasicInfo),
MemoryMappedClock {
koid: Koid,
utc_clock: UtcClock,
},
}Variants§
Vmo(VmoAndBasicInfo)
RingBuf(VmoAndBasicInfo)
The memory object is a bpf ring buffer. The layout it represents is: |Page1 - Page2 - Page3 .. PageN - Page3 .. PageN| where the vmo is |Page1 - Page2 - Page3 .. PageN|
MemoryMappedClock
A memory mapped clock is backed by kernel memory, not by a VMO. So it is handled specially. The lifecycle of this clock is:
- starts off as an empty unmapped thing.
- a MappedClock is created on
map_in_vmar. - a name is added on
set_zx_name. - most clone/resize operations return errors.
- unmapped at the end of the process lifetime.
Implementations§
Source§impl MemoryObject
impl MemoryObject
pub fn as_vmo(&self) -> Option<&Vmo>
Sourcepub fn is_clock(&self) -> bool
pub fn is_clock(&self) -> bool
Returns true if this MemoryObject is a memory mapped clock.
pub fn into_vmo(self) -> Option<Vmo>
pub fn get_content_size(&self) -> u64
pub fn set_content_size(&self, size: u64) -> Result<(), Status>
pub fn get_size(&self) -> u64
pub fn set_size(&self, size: u64) -> Result<(), Status>
pub fn create_child( &self, option: VmoChildOptions, offset: u64, size: u64, ) -> Result<Self, Status>
Sourcepub fn create_private_child(&self) -> Result<Self, Status>
pub fn create_private_child(&self) -> Result<Self, Status>
Creates a writable SNAPSHOT_AT_LEAST_ON_WRITE child spanning all of this memory, for use
as the backing of a private mapping.
Zircon removes Rights::EXECUTE from snapshot children created without NO_WRITE (see
zx_vmo_create_child). If this memory has Rights::EXECUTE, the right is restored on the
child so that the private mapping can still be made executable.
pub fn duplicate_handle(&self, rights: Rights) -> Result<Self, Status>
pub fn read(&self, data: &mut [u8], offset: u64) -> Result<(), Status>
pub fn read_to_array<T: Copy + FromBytes, const N: usize>( &self, offset: u64, ) -> Result<[T; N], Status>
pub fn read_to_vec(&self, offset: u64, length: u64) -> Result<Vec<u8>, Status>
pub fn read_uninit<'a>( &self, data: &'a mut [MaybeUninit<u8>], offset: u64, ) -> Result<&'a mut [u8], Status>
Sourcepub unsafe fn read_raw(
&self,
buffer: *mut u8,
buffer_length: usize,
offset: u64,
) -> Result<(), Status>
pub unsafe fn read_raw( &self, buffer: *mut u8, buffer_length: usize, offset: u64, ) -> Result<(), Status>
Sourcepub fn get_koid(&self) -> Koid
pub fn get_koid(&self) -> Koid
Returns the koid of the underlying memory-like object.
Should be cheap to call frequently.
Sourcepub fn get_rights(&self) -> Rights
pub fn get_rights(&self) -> Rights
Returns the rights of the underlying memory-like object.
Sourcepub fn info(&self) -> Result<VmoInfo, Errno>
pub fn info(&self) -> Result<VmoInfo, Errno>
Returns zx::VmoInfo for a memory object that supports it.
§Panics
Calling info on a MemoryObject that is not represented by a VMO
will panic. To avoid this in code, call is_clock before attempting.
pub fn set_zx_name(&self, name: &[u8])
pub fn with_zx_name(self, name: &[u8]) -> Self
pub fn op_range(&self, op: VmoOp, offset: u64, size: u64) -> Result<(), Status>
pub fn replace_as_executable(self, vmex: &Resource) -> Result<Self, Status>
pub fn map_in_vmar( &self, vmar: &Vmar, vmar_offset: usize, memory_offset: u64, len: usize, flags: VmarFlags, ) -> Result<usize, Status>
pub fn memmove( &self, options: TransferDataOptions, dst_offset: u64, src_offset: u64, size: u64, ) -> Result<(), Status>
pub fn clone_memory( self: &Arc<Self>, rights: Rights, options: MappingOptions, ) -> Result<Arc<Self>, Errno>
Trait Implementations§
Source§impl Debug for MemoryObject
impl Debug for MemoryObject
impl Eq for MemoryObject
Source§impl From<Clock<BootTimeline, UtcTimeline>> for MemoryObject
impl From<Clock<BootTimeline, UtcTimeline>> for MemoryObject
Source§fn from(utc_clock: UtcClock) -> MemoryObject
fn from(utc_clock: UtcClock) -> MemoryObject
Source§impl From<Vmo> for MemoryObject
impl From<Vmo> for MemoryObject
Source§impl PartialEq for MemoryObject
impl PartialEq for MemoryObject
impl RcuDroppable for MemoryObject
Auto Trait Implementations§
impl !Freeze for MemoryObject
impl RefUnwindSafe for MemoryObject
impl Send for MemoryObject
impl Sync for MemoryObject
impl Unpin for MemoryObject
impl UnsafeUnpin for MemoryObject
impl UnwindSafe for MemoryObject
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
fn fidl_into_native(self) -> Box<N>
§impl<T> InstanceFromServiceTransport<T> for T
impl<T> InstanceFromServiceTransport<T> for T
§fn from_service_transport(handle: T) -> T
fn from_service_transport(handle: T) -> T
T to [Self]Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more