pub struct IoVector<'a> { /* private fields */ }Expand description
Vector of memory buffers.
Implementations§
Source§impl<'a> IoVector<'a>
impl<'a> IoVector<'a>
Sourcepub fn with_capacity(cap: usize) -> Self
pub fn with_capacity(cap: usize) -> Self
Create an empty vector, pre-allocating space for cap buffers.
This does not allocate an memory buffer, only space in the buffer vector.
Sourcepub fn push_ioslice(&mut self, ioslice: IoSlice<'a>)
pub fn push_ioslice(&mut self, ioslice: IoSlice<'a>)
Append a slice.
Sourcepub fn insert(&mut self, index: usize, slice: &'a [u8])
pub fn insert(&mut self, index: usize, slice: &'a [u8])
Insert a slice at the given index in the buffer vector.
Sourcepub fn buffer_count(&self) -> usize
pub fn buffer_count(&self) -> usize
Return the number of buffers in this vector.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Return true if and only if this vector’s length is zero.
Synonymous with whether this vector’s buffer count is zero.
Sourcepub fn append(&mut self, other: Self)
pub fn append(&mut self, other: Self)
Append all buffers from the given other vector to this vector.
Sourcepub fn split_at(self, mid: u64) -> (Self, Self)
pub fn split_at(self, mid: u64) -> (Self, Self)
Split the vector into two.
The first returned vector contains the bytes in the [..mid] range, and the second
one covers the [mid..] range.
Sourcepub fn split_tail_at(self, mid: u64) -> Self
pub fn split_tail_at(self, mid: u64) -> Self
Like Self::split_at(), but discards the head, only returning the tail.
More efficient than to use self.split_at(mid).1 because the former requires
creating a new Vec object for the head, which this version skips.
Sourcepub fn copy_into_slice(&self, slice: &mut [u8])
pub fn copy_into_slice(&self, slice: &mut [u8])
Copy the data from self into slice.
Both must have the same length.
Sourcepub fn try_into_owned(self, alignment: usize) -> Result<IoBuffer>
pub fn try_into_owned(self, alignment: usize) -> Result<IoBuffer>
Create a single owned IoBuffer with the same data (copied).
Sourcepub unsafe fn as_iovec<'b>(&'b self) -> &'b [iovec]where
Self: 'b,
Available on Unix only.
pub unsafe fn as_iovec<'b>(&'b self) -> &'b [iovec]where
Self: 'b,
Return a corresponding &[libc::iovec].
§Safety
iovec has no lifetime information. Callers must ensure no elements in the
returned slice are used beyond the lifetime '_.
Sourcepub fn is_aligned(&self, mem_alignment: usize, req_alignment: usize) -> bool
pub fn is_aligned(&self, mem_alignment: usize, req_alignment: usize) -> bool
Check whether self is aligned.
Each buffer must be aligned to mem_alignment, and each buffer’s length must be
aligned to both mem_alignment and req_alignment (the I/O request offset/size
alignment).
Sourcepub fn into_inner(self) -> Vec<IoSlice<'a>>
pub fn into_inner(self) -> Vec<IoSlice<'a>>
Return the internal vector of IoSlice objects.
Sourcepub fn with_pushed<'b>(self, slice: &'b [u8]) -> IoVector<'b>where
'a: 'b,
pub fn with_pushed<'b>(self, slice: &'b [u8]) -> IoVector<'b>where
'a: 'b,
Same as Self::push(), but takes ownership of self.
By taking ownership of self and returning it, this method allows reducing the
lifetime of self to that of slice, if necessary.
Sourcepub fn with_inserted<'b>(self, index: usize, slice: &'b [u8]) -> IoVector<'b>where
'a: 'b,
pub fn with_inserted<'b>(self, index: usize, slice: &'b [u8]) -> IoVector<'b>where
'a: 'b,
Same as Self::insert(), but takes ownership of self.
By taking ownership of self and returning it, this method allows reducing the
lifetime of self to that of slice, if necessary.
Source§impl<'a> IoVector<'a>
impl<'a> IoVector<'a>
Sourcepub fn from_volatile_slice<B: BitmapSlice, I: IntoIterator<Item: ImagoAsRef<'a, VolatileSlice<'a, B>>, IntoIter: ExactSizeIterator>>(
slices: I,
) -> (Self, VolatileSliceGuard<'a, PtrGuard, B>)
Available on crate feature vm-memory only.
pub fn from_volatile_slice<B: BitmapSlice, I: IntoIterator<Item: ImagoAsRef<'a, VolatileSlice<'a, B>>, IntoIter: ExactSizeIterator>>( slices: I, ) -> (Self, VolatileSliceGuard<'a, PtrGuard, B>)
vm-memory only.Converts a VolatileSlice array (from vm-memory) into an IoVector.
In addition to a the vector, return a guard that ensures that the memory in slices is
indeed mapped while in use. This guard must not be dropped while this vector is in use!