Struct base::iobuf::IoBufMut

source ·
#[repr(transparent)]
pub struct IoBufMut<'a> { iobuf: IoBuf, phantom: PhantomData<&'a mut [u8]>, }
Expand description

Cross-platform mutable buffer.

This type is essentialy std::io::IoSliceMut, and guaranteed to be ABI-compatible with libc::iovec on Linux/WSABUF on Windows; however, it does NOT automatically deref to &mut [u8], which is critical because it can point to guest memory. (Guest memory is implicitly mutably borrowed by the guest, so another mutable borrow would violate Rust assumptions about references.)

Fields§

§iobuf: IoBuf§phantom: PhantomData<&'a mut [u8]>

Implementations§

source§

impl<'a> IoBufMut<'a>

source

pub fn new(buf: &mut [u8]) -> IoBufMut<'a>

source

pub unsafe fn from_raw_parts(addr: *mut u8, len: usize) -> IoBufMut<'a>

Creates a IoBufMut from a pointer and a length.

Safety

In order to use this method safely, addr must be valid for reads and writes of len bytes and should live for the entire duration of lifetime 'a.

source

pub unsafe fn from_iobuf(iobuf: IoBuf) -> IoBufMut<'a>

Creates a IoBufMut from an IoBuf.

Safety

In order to use this method safely, iobuf must be valid for reads and writes through its length and should live for the entire duration of lifetime 'a.

source

pub fn advance(&mut self, count: usize)

Advance the internal position of the buffer.

Panics if count > self.len().

source

pub fn truncate(&mut self, len: usize)

Shorten the length of the buffer.

Has no effect if len > self.len().

source

pub fn len(&self) -> usize

source

pub fn is_empty(&self) -> bool

source

pub fn as_ptr(&self) -> *const u8

Gets a const pointer to this slice’s memory.

source

pub fn as_mut_ptr(&self) -> *mut u8

Gets a mutable pointer to this slice’s memory.

source

pub fn as_iobufs<'slice>(iovs: &'slice [IoBufMut<'_>]) -> &'slice [IoBuf]

Converts a slice of IoBufMuts into a slice of IoBufs.

source

pub fn as_iobufs_mut<'slice>( iovs: &'slice mut [IoBufMut<'_>] ) -> &'slice mut [IoBuf]

Converts a mutable slice of IoBufMuts into a mutable slice of IoBufs.

Trait Implementations§

source§

impl<'a> AsMut<iovec> for IoBufMut<'a>

source§

fn as_mut(&mut self) -> &mut IoBuf

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<'a> AsRef<iovec> for IoBufMut<'a>

source§

fn as_ref(&self) -> &IoBuf

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<'a> Clone for IoBufMut<'a>

source§

fn clone(&self) -> IoBufMut<'a>

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
source§

impl<'a> Debug for IoBufMut<'a>

source§

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

Formats the value using the given formatter. Read more
source§

impl<'a> Copy for IoBufMut<'a>

source§

impl<'a> Send for IoBufMut<'a>

source§

impl<'a> Sync for IoBufMut<'a>

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for IoBufMut<'a>

§

impl<'a> Unpin for IoBufMut<'a>

§

impl<'a> !UnwindSafe for IoBufMut<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.