pub struct Vmo(/* private fields */);
Expand description
An object representing a Zircon virtual memory object.
As essentially a subtype of Handle
, it can be freely interconverted.
Implementations§
Source§impl Vmo
impl Vmo
Sourcepub fn create(size: u64) -> Result<Vmo, Status>
pub fn create(size: u64) -> Result<Vmo, Status>
Create a virtual memory object.
Wraps the
zx_vmo_create
syscall. See the
Shared Memory: Virtual Memory Objects (VMOs)
for more information.
Sourcepub fn create_with_opts(opts: VmoOptions, size: u64) -> Result<Vmo, Status>
pub fn create_with_opts(opts: VmoOptions, size: u64) -> Result<Vmo, Status>
Create a virtual memory object with options.
Wraps the
zx_vmo_create
syscall, allowing options to be passed.
Sourcepub fn create_contiguous(
bti: &Bti,
size: usize,
alignment_log2: u32,
) -> Result<Vmo, Status>
pub fn create_contiguous( bti: &Bti, size: usize, alignment_log2: u32, ) -> Result<Vmo, Status>
Create a physically contiguous virtual memory object.
Wraps the
zx_vmo_create_contiguous
syscall.
Sourcepub fn read(&self, data: &mut [u8], offset: u64) -> Result<(), Status>
pub fn read(&self, data: &mut [u8], offset: u64) -> Result<(), Status>
Read from a virtual memory object.
Wraps the zx_vmo_read
syscall.
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>
Provides the thinest wrapper possible over zx_vmo_read
.
§Safety
Callers must guarantee that the buffer is valid to write to.
Sourcepub fn read_uninit<'a>(
&self,
data: &'a mut [MaybeUninit<u8>],
offset: u64,
) -> Result<&'a mut [u8], Status>
pub fn read_uninit<'a>( &self, data: &'a mut [MaybeUninit<u8>], offset: u64, ) -> Result<&'a mut [u8], Status>
Same as read, but reads into memory that might not be initialized, returning an initialized slice of bytes on success.
Sourcepub fn read_to_vec(&self, offset: u64, length: u64) -> Result<Vec<u8>, Status>
pub fn read_to_vec(&self, offset: u64, length: u64) -> Result<Vec<u8>, Status>
Same as read, but returns a Vec.
Sourcepub fn read_to_array<T, const N: usize>(
&self,
offset: u64,
) -> Result<[T; N], Status>where
T: FromBytes,
pub fn read_to_array<T, const N: usize>(
&self,
offset: u64,
) -> Result<[T; N], Status>where
T: FromBytes,
Same as read, but returns an array.
Sourcepub fn read_to_object<T>(&self, offset: u64) -> Result<T, Status>where
T: FromBytes,
pub fn read_to_object<T>(&self, offset: u64) -> Result<T, Status>where
T: FromBytes,
Same as read, but returns a T
.
Sourcepub fn write(&self, data: &[u8], offset: u64) -> Result<(), Status>
pub fn write(&self, data: &[u8], offset: u64) -> Result<(), Status>
Write to a virtual memory object.
Wraps the zx_vmo_write
syscall.
Sourcepub fn transfer_data(
&self,
options: TransferDataOptions,
offset: u64,
length: u64,
src_vmo: &Vmo,
src_offset: u64,
) -> Result<(), Status>
pub fn transfer_data( &self, options: TransferDataOptions, offset: u64, length: u64, src_vmo: &Vmo, src_offset: u64, ) -> Result<(), Status>
Efficiently transfers data from one VMO to another.
Sourcepub fn get_size(&self) -> Result<u64, Status>
pub fn get_size(&self) -> Result<u64, Status>
Get the size of a virtual memory object.
Wraps the zx_vmo_get_size
syscall.
Sourcepub fn set_size(&self, size: u64) -> Result<(), Status>
pub fn set_size(&self, size: u64) -> Result<(), Status>
Attempt to change the size of a virtual memory object.
Wraps the zx_vmo_set_size
syscall.
Sourcepub fn get_stream_size(&self) -> Result<u64, Status>
pub fn get_stream_size(&self) -> Result<u64, Status>
Get the stream size of a virtual memory object.
Wraps the zx_vmo_get_stream_size
syscall.
Sourcepub fn set_stream_size(&self, size: u64) -> Result<(), Status>
pub fn set_stream_size(&self, size: u64) -> Result<(), Status>
Attempt to set the stream size of a virtual memory object.
Wraps the zx_vmo_set_stream_size
syscall.
Sourcepub fn set_cache_policy(&self, cache_policy: CachePolicy) -> Result<(), Status>
pub fn set_cache_policy(&self, cache_policy: CachePolicy) -> Result<(), Status>
Attempt to change the cache policy of a virtual memory object.
Wraps the zx_vmo_set_cache_policy
syscall.
Sourcepub fn op_range(&self, op: VmoOp, offset: u64, size: u64) -> Result<(), Status>
pub fn op_range(&self, op: VmoOp, offset: u64, size: u64) -> Result<(), Status>
Perform an operation on a range of a virtual memory object.
Wraps the zx_vmo_op_range syscall.
Sourcepub fn info(&self) -> Result<VmoInfo, Status>
pub fn info(&self) -> Result<VmoInfo, Status>
Wraps the zx_object_get_info syscall for the ZX_INFO_VMO topic.
Sourcepub fn create_child(
&self,
opts: VmoChildOptions,
offset: u64,
size: u64,
) -> Result<Vmo, Status>
pub fn create_child( &self, opts: VmoChildOptions, offset: u64, size: u64, ) -> Result<Vmo, Status>
Create a new virtual memory object that clones a range of this one.
Wraps the zx_vmo_create_child syscall.
Sourcepub fn replace_as_executable(self, vmex: &Resource) -> Result<Vmo, Status>
pub fn replace_as_executable(self, vmex: &Resource) -> Result<Vmo, Status>
Replace a VMO, adding execute rights.
Wraps the zx_vmo_replace_as_executable syscall.
Trait Implementations§
Source§impl AsHandleRef for Vmo
impl AsHandleRef for Vmo
Source§fn as_handle_ref(&self) -> Unowned<'_, Handle>
fn as_handle_ref(&self) -> Unowned<'_, Handle>
object_wait_many
.Source§fn raw_handle(&self) -> u32
fn raw_handle(&self) -> u32
Source§fn signal_handle(
&self,
clear_mask: Signals,
set_mask: Signals,
) -> Result<(), Status>
fn signal_handle( &self, clear_mask: Signals, set_mask: Signals, ) -> Result<(), Status>
Source§fn wait_handle(
&self,
signals: Signals,
deadline: Instant<MonotonicTimeline>,
) -> WaitResult
fn wait_handle( &self, signals: Signals, deadline: Instant<MonotonicTimeline>, ) -> WaitResult
Source§fn wait_async_handle(
&self,
port: &Port,
key: u64,
signals: Signals,
options: WaitAsyncOpts,
) -> Result<(), Status>
fn wait_async_handle( &self, port: &Port, key: u64, signals: Signals, options: WaitAsyncOpts, ) -> Result<(), Status>
Source§fn get_name(&self) -> Result<Name, Status>
fn get_name(&self) -> Result<Name, Status>
Source§fn set_name(&self, name: &Name) -> Result<(), Status>
fn set_name(&self, name: &Name) -> Result<(), Status>
Source§fn basic_info(&self) -> Result<HandleBasicInfo, Status>
fn basic_info(&self) -> Result<HandleBasicInfo, Status>
Source§fn count_info(&self) -> Result<HandleCountInfo, Status>
fn count_info(&self) -> Result<HandleCountInfo, Status>
§impl FromWire<WireHandle> for Vmo
impl FromWire<WireHandle> for Vmo
§fn from_wire(wire: WireHandle) -> Vmo
fn from_wire(wire: WireHandle) -> Vmo
wire
to this type.§const COPY_OPTIMIZATION: CopyOptimization<W, Self> = _
const COPY_OPTIMIZATION: CopyOptimization<W, Self> = _
§impl FromWireOption<WireOptionalHandle> for Vmo
impl FromWireOption<WireOptionalHandle> for Vmo
§fn from_wire_option(wire: WireOptionalHandle) -> Option<Vmo>
fn from_wire_option(wire: WireOptionalHandle) -> Option<Vmo>
wire
to an option of this type.Source§impl HandleBased for Vmo
impl HandleBased for Vmo
Source§fn duplicate_handle(&self, rights: Rights) -> Result<Self, Status>
fn duplicate_handle(&self, rights: Rights) -> Result<Self, Status>
Source§fn replace_handle(self, rights: Rights) -> Result<Self, Status>
fn replace_handle(self, rights: Rights) -> Result<Self, Status>
Source§fn into_handle(self) -> Handle
fn into_handle(self) -> Handle
Source§fn from_handle(handle: Handle) -> Self
fn from_handle(handle: Handle) -> Self
Source§fn into_handle_based<H>(self) -> Hwhere
H: HandleBased,
fn into_handle_based<H>(self) -> Hwhere
H: HandleBased,
Source§fn from_handle_based<H>(h: H) -> Selfwhere
H: HandleBased,
fn from_handle_based<H>(h: H) -> Selfwhere
H: HandleBased,
fn is_invalid_handle(&self) -> bool
Source§impl Ord for Vmo
impl Ord for Vmo
Source§impl PartialOrd for Vmo
impl PartialOrd for Vmo
impl Eq for Vmo
impl StructuralPartialEq for Vmo
Auto Trait Implementations§
impl Freeze for Vmo
impl RefUnwindSafe for Vmo
impl Send for Vmo
impl Sync for Vmo
impl Unpin for Vmo
impl UnwindSafe for Vmo
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> EncodableAsHandle for Twhere
T: HandleBased,
impl<T> EncodableAsHandle for Twhere
T: HandleBased,
Source§type Dialect = DefaultFuchsiaResourceDialect
type Dialect = DefaultFuchsiaResourceDialect
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<T, W> FromWireOption<WireBox<'_, W>> for Twhere
T: FromWire<W>,
impl<T, W> FromWireOption<WireBox<'_, W>> for Twhere
T: FromWire<W>,
§fn from_wire_option(wire: WireBox<'_, W>) -> Option<T>
fn from_wire_option(wire: WireBox<'_, W>) -> Option<T>
wire
to an option of this type.