pub(crate) trait IoBufferRefTrait<'a>: Sized {
type SliceType<T: Copy + Sized + 'a>;
type PointerType<T: Copy + Sized + 'a>;
// Required methods
fn from_slice(slice: Self::SliceType<u8>) -> Self;
fn try_into_owned(self, alignment: usize) -> Result<IoBuffer>;
fn len(&self) -> usize;
fn as_ptr(&self) -> Self::PointerType<u8>;
unsafe fn into_typed_slice<T: Copy + Sized>(self) -> Self::SliceType<T>;
fn split_at(self, mid: usize) -> (Self, Self);
fn into_ref(self) -> IoBufferRef<'a>;
// Provided methods
fn is_empty(&self) -> bool { ... }
fn into_slice(self) -> Self::SliceType<u8> { ... }
}
Expand description
Common functions for both IoBufferRef
and IoBufferMut
.
Required Associated Types§
Sourcetype PointerType<T: Copy + Sized + 'a>
type PointerType<T: Copy + Sized + 'a>
*const T
or *mut T
.
Required Methods§
Sourcefn from_slice(slice: Self::SliceType<u8>) -> Self
fn from_slice(slice: Self::SliceType<u8>) -> Self
Create a reference to a slice.
Sourcefn try_into_owned(self, alignment: usize) -> Result<IoBuffer>
fn try_into_owned(self, alignment: usize) -> Result<IoBuffer>
Create an owned IoBuffer
with the same data (copied).
Sourcefn as_ptr(&self) -> Self::PointerType<u8>
fn as_ptr(&self) -> Self::PointerType<u8>
Return the pointer to the start of the buffer.
Sourceunsafe fn into_typed_slice<T: Copy + Sized>(self) -> Self::SliceType<T>
unsafe fn into_typed_slice<T: Copy + Sized>(self) -> Self::SliceType<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.
Sourcefn split_at(self, mid: usize) -> (Self, Self)
fn split_at(self, mid: usize) -> (Self, Self)
Split the buffer at mid
.
Return &self[..mid]
and &self[mid..]
.
If mid > self.len()
, return &self[..]
and []
.
Sourcefn into_ref(self) -> IoBufferRef<'a>
fn into_ref(self) -> IoBufferRef<'a>
Make this reference immutable.
Provided Methods§
Sourcefn into_slice(self) -> Self::SliceType<u8>
fn into_slice(self) -> Self::SliceType<u8>
Turn this reference into a slice.
References to IoBuffer
s 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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.