Type Alias IovecArray

Source
pub type IovecArray = GuestPtr<[Iovec]>;
Available on crate feature preview1 only.

Aliased Type§

struct IovecArray { /* private fields */ }

Implementations

§

impl<T> GuestPtr<[T]>

pub fn offset_base(&self) -> u32

For slices, specifically returns the relative pointer to the base of the array.

This is similar to <[T]>::as_ptr()

pub fn len(&self) -> u32

For slices, returns the length of the slice, in elements.

pub fn iter(&self) -> impl ExactSizeIterator
where T: GuestType,

Returns an iterator over interior pointers.

Each item is a Result indicating whether it overflowed past the end of the address space or not.

pub fn as_ptr(&self) -> GuestPtr<T>

Returns a GuestPtr pointing to the base of the array for the interior type T.

pub fn get(&self, index: u32) -> Option<GuestPtr<T>>
where T: GuestType,

pub fn get_range(&self, r: Range<u32>) -> Option<GuestPtr<[T]>>
where T: GuestType,

§

impl<T> GuestPtr<T>
where T: Pointee + ?Sized,

pub fn new(pointer: <T as Pointee>::Pointer) -> GuestPtr<T>

Creates a new GuestPtr from the given mem and pointer values.

Note that for sized types like u32, GuestPtr<T>, etc, the pointer value is a u32 offset into guest memory. For slices and strings, pointer is a (u32, u32) offset/length pair.

pub fn offset(&self) -> <T as Pointee>::Pointer

Returns the offset of this pointer in guest memory.

Note that for sized types this returns a u32, but for slices and strings it returns a (u32, u32) pointer/length pair.

pub fn cast<U>(&self) -> GuestPtr<U>
where U: Pointee<Pointer = <T as Pointee>::Pointer> + ?Sized,

Casts this GuestPtr type to a different type.

This is a safe method which is useful for simply reinterpreting the type parameter on this GuestPtr. Note that this is a safe method, where again there’s no guarantees about alignment, validity, in-bounds-ness, etc of the returned pointer.

pub fn add(&self, amt: u32) -> Result<GuestPtr<T>, GuestError>
where T: GuestType + Pointee<Pointer = u32>,

Performs pointer arithmetic on this pointer, moving the pointer forward amt slots.

This will either return the resulting pointer or Err if the pointer arithmetic calculation would overflow around the end of the address space.

pub fn as_array(&self, elems: u32) -> GuestPtr<[T]>
where T: GuestType + Pointee<Pointer = u32>,

Returns a GuestPtr for an array of Ts using this pointer as the base.

Trait Implementations

§

impl<T> Clone for GuestPtr<T>
where T: Pointee + ?Sized,

§

fn clone(&self) -> GuestPtr<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<T> Debug for GuestPtr<T>
where T: Pointee + ?Sized,

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<T> GuestType for GuestPtr<[T]>
where T: GuestType,

§

fn guest_size() -> u32

Returns the size, in bytes, of this type in the guest memory.
§

fn guest_align() -> usize

Returns the required alignment of this type, in bytes, for both guest and host memory.
§

fn read( mem: &GuestMemory<'_>, ptr: GuestPtr<GuestPtr<[T]>>, ) -> Result<GuestPtr<[T]>, GuestError>

Reads this value from the provided ptr. Read more
§

fn write( mem: &mut GuestMemory<'_>, ptr: GuestPtr<GuestPtr<[T]>>, val: GuestPtr<[T]>, ) -> Result<(), GuestError>

Writes a value to ptr after verifying that ptr is indeed valid to store val. Read more
§

impl<T> GuestType for GuestPtr<T>

§

fn guest_size() -> u32

Returns the size, in bytes, of this type in the guest memory.
§

fn guest_align() -> usize

Returns the required alignment of this type, in bytes, for both guest and host memory.
§

fn read( mem: &GuestMemory<'_>, ptr: GuestPtr<GuestPtr<T>>, ) -> Result<GuestPtr<T>, GuestError>

Reads this value from the provided ptr. Read more
§

fn write( mem: &mut GuestMemory<'_>, ptr: GuestPtr<GuestPtr<T>>, val: GuestPtr<T>, ) -> Result<(), GuestError>

Writes a value to ptr after verifying that ptr is indeed valid to store val. Read more
§

impl<T> PartialEq for GuestPtr<T>
where T: Pointee + ?Sized,

§

fn eq(&self, other: &GuestPtr<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<T> Copy for GuestPtr<T>
where T: Pointee + ?Sized,