pub(crate) trait IoVectorTrait: Sized {
type SliceType;
type BufferType;
Show 16 methods
// Required methods
fn new() -> Self;
fn with_capacity(cap: usize) -> Self;
fn push(&mut self, slice: Self::SliceType);
fn push_ioslice(&mut self, ioslice: Self::BufferType);
fn insert(&mut self, index: usize, slice: Self::SliceType);
fn len(&self) -> u64;
fn buffer_count(&self) -> usize;
fn append(&mut self, other: Self);
fn split_at(self, mid: u64) -> (Self, Self);
fn split_tail_at(self, mid: u64) -> Self;
fn copy_into_slice(&self, slice: &mut [u8]);
fn try_into_owned(self, alignment: usize) -> Result<IoBuffer>;
unsafe fn as_iovec<'a>(&'a self) -> &'a [iovec]
where Self: 'a;
fn is_aligned(&self, mem_alignment: usize, req_alignment: usize) -> bool;
fn into_inner(self) -> Vec<Self::BufferType>;
// Provided method
fn is_empty(&self) -> bool { ... }
}
Expand description
Common functions for both IoVector
and IoVectorMut
.
Required Associated Types§
Sourcetype BufferType
type BufferType
IoSlice
or IoSliceMut
.
Required Methods§
Sourcefn with_capacity(cap: usize) -> Self
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.
Sourcefn push_ioslice(&mut self, ioslice: Self::BufferType)
fn push_ioslice(&mut self, ioslice: Self::BufferType)
Append a slice.
Sourcefn insert(&mut self, index: usize, slice: Self::SliceType)
fn insert(&mut self, index: usize, slice: Self::SliceType)
Insert a slice at the given index
in the buffer vector.
Sourcefn buffer_count(&self) -> usize
fn buffer_count(&self) -> usize
Return the number of buffers in this vector.
Sourcefn append(&mut self, other: Self)
fn append(&mut self, other: Self)
Append all buffers from the given other vector to this vector.
Sourcefn split_at(self, mid: u64) -> (Self, Self)
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.
Sourcefn split_tail_at(self, mid: u64) -> Self
fn split_tail_at(self, mid: u64) -> Self
Like IoVectorTrait::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.
Sourcefn copy_into_slice(&self, slice: &mut [u8])
fn copy_into_slice(&self, slice: &mut [u8])
Copy the data from self
into slice
.
Both must have the same length.
Sourcefn try_into_owned(self, alignment: usize) -> Result<IoBuffer>
fn try_into_owned(self, alignment: usize) -> Result<IoBuffer>
Create a single owned IoBuffer
with the same data (copied).
Sourceunsafe fn as_iovec<'a>(&'a self) -> &'a [iovec]where
Self: 'a,
unsafe fn as_iovec<'a>(&'a self) -> &'a [iovec]where
Self: 'a,
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 '_
.
Sourcefn is_aligned(&self, mem_alignment: usize, req_alignment: usize) -> bool
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).
Sourcefn into_inner(self) -> Vec<Self::BufferType>
fn into_inner(self) -> Vec<Self::BufferType>
Return the internal vector of IoSlice
objects.
Provided Methods§
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.