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>
impl<'a> IoBufferRef<'a>
Sourcepub fn from_slice(slice: &'a [u8]) -> Self
pub fn from_slice(slice: &'a [u8]) -> Self
Create a reference to a slice.
Sourcepub fn try_into_owned(self, alignment: usize) -> Result<IoBuffer>
pub fn try_into_owned(self, alignment: usize) -> Result<IoBuffer>
Create an owned IoBuffer
with the same data (copied).
Sourcepub fn into_slice(self) -> &'a [u8] ⓘ
pub fn into_slice(self) -> &'a [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.
Sourcepub unsafe fn into_typed_slice<T: Copy + Sized>(self) -> &'a [T]
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.
Sourcepub fn split_at(self, mid: usize) -> (IoBufferRef<'a>, IoBufferRef<'a>)
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 []
.
Sourcepub fn into_ref(self) -> IoBufferRef<'a>
pub fn into_ref(self) -> IoBufferRef<'a>
Make this reference immutable.
Trait Implementations§
Source§impl<'a> From<IoBufferRef<'a>> for IoSlice<'a>
impl<'a> From<IoBufferRef<'a>> for IoSlice<'a>
Source§fn from(buf: IoBufferRef<'a>) -> Self
fn from(buf: IoBufferRef<'a>) -> Self
Converts to this type from the input type.
Source§impl<'a> From<IoBufferRef<'a>> for IoVector<'a>
impl<'a> From<IoBufferRef<'a>> for IoVector<'a>
Source§fn from(buffer: IoBufferRef<'a>) -> Self
fn from(buffer: IoBufferRef<'a>) -> Self
Converts to this type from the input type.
Source§impl<'a> From<IoSlice<'a>> for IoBufferRef<'a>
impl<'a> From<IoSlice<'a>> for IoBufferRef<'a>
Source§impl<'a> IoBufferRefTrait<'a> for IoBufferRef<'a>
impl<'a> IoBufferRefTrait<'a> for IoBufferRef<'a>
Source§fn from_slice(slice: Self::SliceType<u8>) -> Self
fn from_slice(slice: Self::SliceType<u8>) -> Self
Create a reference to a slice.
Source§fn 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).Source§fn as_ptr(&self) -> Self::PointerType<u8>
fn as_ptr(&self) -> Self::PointerType<u8>
Return the pointer to the start of the buffer.
Source§fn into_ref(self) -> IoBufferRef<'a>
fn into_ref(self) -> IoBufferRef<'a>
Make this reference immutable.
impl Send for IoBufferRef<'_>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more