Trait compio_buf::IoVectoredBuf
source · pub trait IoVectoredBuf: Sized + 'static {
// Required methods
fn as_dyn_bufs(&self) -> impl Iterator<Item = &dyn IoBuf>;
fn owned_iter(
self,
) -> Result<OwnedIter<impl OwnedIterator<Inner = Self>>, Self>;
// Provided method
unsafe fn as_io_slices(&self) -> Vec<IoSlice> { ... }
}
Expand description
A trait for vectored buffers.
Required Methods§
sourcefn as_dyn_bufs(&self) -> impl Iterator<Item = &dyn IoBuf>
fn as_dyn_bufs(&self) -> impl Iterator<Item = &dyn IoBuf>
Iterate the inner buffers.
sourcefn owned_iter(self) -> Result<OwnedIter<impl OwnedIterator<Inner = Self>>, Self>
fn owned_iter(self) -> Result<OwnedIter<impl OwnedIterator<Inner = Self>>, Self>
Create an owned iterator to make it easy to pass this vectored buffer as a regular buffer.
use compio_buf::{IoBuf, IoVectoredBuf};
let bufs = [vec![1u8, 2], vec![3, 4]];
let iter = bufs.owned_iter().unwrap();
assert_eq!(iter.as_slice(), &[1, 2]);
let iter = iter.next().unwrap();
assert_eq!(iter.as_slice(), &[3, 4]);
let iter = iter.next();
assert!(iter.is_err());
The time complexity of the returned iterator depends on the
implementation of Iterator::nth
of IoVectoredBuf::as_dyn_bufs
.
Provided Methods§
Object Safety§
This trait is not object safe.
Implementations on Foreign Types§
source§impl<T: IoBuf> IoVectoredBuf for &'static [T]
impl<T: IoBuf> IoVectoredBuf for &'static [T]
fn as_dyn_bufs(&self) -> impl Iterator<Item = &dyn IoBuf>
fn owned_iter(self) -> Result<OwnedIter<impl OwnedIterator<Inner = Self>>, Self>
source§impl<T: IoBuf> IoVectoredBuf for &'static mut [T]
impl<T: IoBuf> IoVectoredBuf for &'static mut [T]
fn as_dyn_bufs(&self) -> impl Iterator<Item = &dyn IoBuf>
fn owned_iter(self) -> Result<OwnedIter<impl OwnedIterator<Inner = Self>>, Self>
source§impl<T: IoBuf, A: Allocator + 'static> IoVectoredBuf for Vec<T, A>
impl<T: IoBuf, A: Allocator + 'static> IoVectoredBuf for Vec<T, A>
fn as_dyn_bufs(&self) -> impl Iterator<Item = &dyn IoBuf>
fn owned_iter(self) -> Result<OwnedIter<impl OwnedIterator<Inner = Self>>, Self>
source§impl<T: IoBuf, const N: usize> IoVectoredBuf for [T; N]
impl<T: IoBuf, const N: usize> IoVectoredBuf for [T; N]
fn as_dyn_bufs(&self) -> impl Iterator<Item = &dyn IoBuf>
fn owned_iter(self) -> Result<OwnedIter<impl OwnedIterator<Inner = Self>>, Self>
source§impl<T: IoBuf, const N: usize> IoVectoredBuf for ArrayVec<T, N>
Available on crate feature arrayvec
only.
impl<T: IoBuf, const N: usize> IoVectoredBuf for ArrayVec<T, N>
Available on crate feature
arrayvec
only.