Struct Vmo
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§
§impl Vmo
impl Vmo
pub 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.
pub 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.
pub 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.
pub 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.
pub unsafe fn read_raw<T>(
&self,
buffer: *mut T,
buffer_length: usize,
offset: u64,
) -> Result<(), Status>where
T: FromBytes,
pub unsafe fn read_raw<T>(
&self,
buffer: *mut T,
buffer_length: usize,
offset: u64,
) -> Result<(), Status>where
T: FromBytes,
Provides a very thin wrapper over zx_vmo_read
.
§Safety
Callers must guarantee that the buffer is valid to write to.
pub fn read_uninit<'a, T>(
&self,
data: &'a mut [MaybeUninit<T>],
offset: u64,
) -> Result<&'a mut [T], Status>where
T: Copy + FromBytes,
pub fn read_uninit<'a, T>(
&self,
data: &'a mut [MaybeUninit<T>],
offset: u64,
) -> Result<&'a mut [T], Status>where
T: Copy + FromBytes,
Same as read, but reads into memory that might not be initialized, returning an initialized slice of bytes on success.
Copy
is required to ensure that there are no custom Drop
implementations. It is
difficult to correctly run custom drop code after initializing a MaybeUninit
.
pub fn read_to_vec<T>(&self, offset: u64, length: u64) -> Result<Vec<T>, Status>where
T: Copy + FromBytes,
pub fn read_to_vec<T>(&self, offset: u64, length: u64) -> Result<Vec<T>, Status>where
T: Copy + FromBytes,
Same as read, but returns a Vec.
pub fn read_to_array<T, const N: usize>(
&self,
offset: u64,
) -> Result<[T; N], Status>where
T: Copy + FromBytes,
pub fn read_to_array<T, const N: usize>(
&self,
offset: u64,
) -> Result<[T; N], Status>where
T: Copy + FromBytes,
Same as read, but returns an array.
pub fn read_to_object<T>(&self, offset: u64) -> Result<T, Status>where
T: Copy + FromBytes,
pub fn read_to_object<T>(&self, offset: u64) -> Result<T, Status>where
T: Copy + FromBytes,
Same as read, but returns a T
.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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.
pub 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§
§impl AsHandleRef for Vmo
impl AsHandleRef for Vmo
§fn as_handle_ref(&self) -> Unowned<'_, Handle>
fn as_handle_ref(&self) -> Unowned<'_, Handle>
object_wait_many
.§fn raw_handle(&self) -> u32
fn raw_handle(&self) -> u32
§fn signal_handle(
&self,
clear_mask: Signals,
set_mask: Signals,
) -> Result<(), Status>
fn signal_handle( &self, clear_mask: Signals, set_mask: Signals, ) -> Result<(), Status>
§fn wait_handle(
&self,
signals: Signals,
deadline: Instant<MonotonicTimeline>,
) -> WaitResult
fn wait_handle( &self, signals: Signals, deadline: Instant<MonotonicTimeline>, ) -> WaitResult
§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>
§fn get_name(&self) -> Result<Name, Status>
fn get_name(&self) -> Result<Name, Status>
§fn set_name(&self, name: &Name) -> Result<(), Status>
fn set_name(&self, name: &Name) -> Result<(), Status>
§fn basic_info(&self) -> Result<HandleBasicInfo, Status>
fn basic_info(&self) -> Result<HandleBasicInfo, Status>
§fn count_info(&self) -> Result<HandleCountInfo, Status>
fn count_info(&self) -> Result<HandleCountInfo, Status>
Source§impl CompatFrom<Vmo> for Vmo
impl CompatFrom<Vmo> for Vmo
Source§fn compat_from(value: Vmo) -> Vmo
fn compat_from(value: Vmo) -> Vmo
value
into a value of this type.Source§impl Encodable for Vmo
impl Encodable for Vmo
Source§const COPY_OPTIMIZATION: CopyOptimization<Self, Self::Encoded> = _
const COPY_OPTIMIZATION: CopyOptimization<Self, Self::Encoded> = _
Self
to Self::Encoded
is equivalent to copying the raw bytes
of Self
. Read moreSource§impl EncodableOption for Vmo
impl EncodableOption for Vmo
Source§type EncodedOption = WireOptionalVmo
type EncodedOption = WireOptionalVmo
Source§impl<E> EncodeOption<E> for Vmowhere
E: HandleEncoder + ?Sized,
impl<E> EncodeOption<E> for Vmowhere
E: HandleEncoder + ?Sized,
Source§fn encode_option(
this: Option<Vmo>,
encoder: &mut E,
out: &mut MaybeUninit<<Vmo as EncodableOption>::EncodedOption>,
) -> Result<(), EncodeError>
fn encode_option( this: Option<Vmo>, encoder: &mut E, out: &mut MaybeUninit<<Vmo as EncodableOption>::EncodedOption>, ) -> Result<(), EncodeError>
Source§impl FromWire<WireVmo> for Vmo
impl FromWire<WireVmo> for Vmo
Source§const COPY_OPTIMIZATION: CopyOptimization<W, Self> = _
const COPY_OPTIMIZATION: CopyOptimization<W, Self> = _
Source§impl FromWireOption<WireOptionalVmo> for Vmo
impl FromWireOption<WireOptionalVmo> for Vmo
Source§fn from_wire_option(wire: WireOptionalVmo) -> Option<Vmo>
fn from_wire_option(wire: WireOptionalVmo) -> Option<Vmo>
wire
to an option of this type.§impl HandleBased for Vmo
impl HandleBased for Vmo
§fn duplicate_handle(&self, rights: Rights) -> Result<Self, Status>
fn duplicate_handle(&self, rights: Rights) -> Result<Self, Status>
§fn replace_handle(self, rights: Rights) -> Result<Self, Status>
fn replace_handle(self, rights: Rights) -> Result<Self, Status>
§fn into_handle(self) -> Handle
fn into_handle(self) -> Handle
§fn from_handle(handle: Handle) -> Self
fn from_handle(handle: Handle) -> Self
§fn into_handle_based<H>(self) -> Hwhere
H: HandleBased,
fn into_handle_based<H>(self) -> Hwhere
H: HandleBased,
§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
§impl Ord for Vmo
impl Ord for Vmo
§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
§impl<T> EncodableAsHandle for Twhere
T: HandleBased,
impl<T> EncodableAsHandle for Twhere
T: HandleBased,
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
Source§impl<T, W> FromWireOption<WireBox<'_, W>> for Twhere
T: FromWire<W>,
impl<T, W> FromWireOption<WireBox<'_, W>> for Twhere
T: FromWire<W>,
Source§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.