Trait IoVectorTrait

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

Source

type SliceType

&[u8] or &mut [u8].

Source

type BufferType

IoSlice or IoSliceMut.

Required Methods§

Source

fn new() -> Self

Create an empty vector.

Source

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.

Source

fn push(&mut self, slice: Self::SliceType)

Append a slice.

Source

fn push_ioslice(&mut self, ioslice: Self::BufferType)

Append a slice.

Source

fn insert(&mut self, index: usize, slice: Self::SliceType)

Insert a slice at the given index in the buffer vector.

Source

fn len(&self) -> u64

Return the sum total length in bytes of all buffers in this vector.

Source

fn buffer_count(&self) -> usize

Return the number of buffers in this vector.

Source

fn append(&mut self, other: Self)

Append all buffers from the given other vector to this vector.

Source

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.

Source

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.

Source

fn copy_into_slice(&self, slice: &mut [u8])

Copy the data from self into slice.

Both must have the same length.

Source

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

Create a single owned IoBuffer with the same data (copied).

Source

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 '_.

Source

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

Source

fn into_inner(self) -> Vec<Self::BufferType>

Return the internal vector of IoSlice objects.

Provided Methods§

Source

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.

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.

Implementors§