Struct IoBufferRef

Source
pub struct IoBufferRef<'a> {
    pointer: *const u8,
    size: usize,
    _lifetime: PhantomData<&'a [u8]>,
}
Expand description

Reference to any immutable memory buffer.

Fields§

§pointer: *const u8

Raw pointer to the start of the buffer.

§size: usize

Size in bytes.

§_lifetime: PhantomData<&'a [u8]>

Lifetime marker.

Implementations§

Source§

impl<'a> IoBufferRef<'a>

Source

pub fn from_slice(slice: &'a [u8]) -> Self

Create a reference to a slice.

Source

pub fn try_into_owned(self, alignment: usize) -> Result<IoBuffer>

Create an owned IoBuffer with the same data (copied).

Source

pub fn len(&self) -> usize

Size in bytes.

Source

pub fn is_empty(&self) -> bool

Whether the length is 0.

Source

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

Return the pointer to the start of the buffer.

Source

pub fn into_slice(self) -> &'a [u8]

Turn this reference into a slice.

References to IoBuffers must not be copied/cloned (so they can only be accessed once; they are considered volatile due to potential VM guest accesses), so this consumes the object.

Source

pub unsafe fn into_typed_slice<T: Copy + Sized>(self) -> &'a [T]

Turn this reference into a slice with the given element type.

§Safety

Caller must ensure that alignment and length requirements are met and that the resulting data is valid.

Source

pub fn split_at(self, mid: usize) -> (IoBufferRef<'a>, IoBufferRef<'a>)

Split the buffer at mid.

Return &self[..mid] and &self[mid..].

If mid > self.len(), return &self[..] and [].

Source

pub fn into_ref(self) -> IoBufferRef<'a>

Make this reference immutable.

Trait Implementations§

Source§

impl<'a> From<IoBufferRef<'a>> for IoSlice<'a>

Source§

fn from(buf: IoBufferRef<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<IoBufferRef<'a>> for IoVector<'a>

Source§

fn from(buffer: IoBufferRef<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<IoSlice<'a>> for IoBufferRef<'a>

Source§

fn from(slice: IoSlice<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> IoBufferRefTrait<'a> for IoBufferRef<'a>

Source§

type SliceType<T: Copy + Sized + 'a> = &'a [T]

&[T] or &mut [T].
Source§

type PointerType<T: Copy + Sized + 'a> = *const T

*const T or *mut T.
Source§

fn from_slice(slice: Self::SliceType<u8>) -> Self

Create a reference to a slice.
Source§

fn try_into_owned(self, alignment: usize) -> Result<IoBuffer>

Create an owned IoBuffer with the same data (copied).
Source§

fn len(&self) -> usize

Size in bytes.
Source§

fn as_ptr(&self) -> Self::PointerType<u8>

Return the pointer to the start of the buffer.
Source§

fn split_at(self, mid: usize) -> (Self, Self)

Split the buffer at mid. Read more
Source§

fn into_ref(self) -> IoBufferRef<'a>

Make this reference immutable.
Source§

unsafe fn into_typed_slice<T: Copy + Sized>(self) -> Self::SliceType<T>

Turn this reference into a slice with the given element type. Read more
Source§

fn is_empty(&self) -> bool

Whether the length is 0.
Source§

fn into_slice(self) -> Self::SliceType<u8>

Turn this reference into a slice. Read more
Source§

impl Send for IoBufferRef<'_>

Source§

impl Sync for IoBufferRef<'_>

Auto Trait Implementations§

§

impl<'a> Freeze for IoBufferRef<'a>

§

impl<'a> RefUnwindSafe for IoBufferRef<'a>

§

impl<'a> Unpin for IoBufferRef<'a>

§

impl<'a> UnwindSafe for IoBufferRef<'a>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more