Struct fidl::handle::fuchsia_handles::Vmo
source · 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>,
) -> Result<Signals, Status>
fn wait_handle( &self, signals: Signals, deadline: Instant<MonotonicTimeline>, ) -> Result<Signals, Status>
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>
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
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more