Function write_all_vectored
pub fn write_all_vectored<'a, 'b, W>(writer: &'a mut W, bufs: &'a mut [IoSlice<'b>]) -> WriteAllVectored<'a, 'b, W>
where
W: AsyncWrite + Unpin + ?Sized,
Like write_all but writes all data from multiple buffers into this writer.
This function writes multiple (possibly non-contiguous) buffers into the writer,
using the writev syscall to potentially write in a single system call.
Equivalent to:
async fn write_all_vectored<W: AsyncWrite + Unpin + ?Sized>(
writer: &mut W,
mut bufs: &mut [IoSlice<'_>]
) -> io::Result<()> {
while !bufs.is_empty() {
let n = write_vectored(writer, bufs).await?;
if n == 0 {
return Err(io::ErrorKind::WriteZero.into());
}
IoSlice::advance_slices(&mut bufs, n);
}
Ok(())
}
Cancel safety
This method is not cancellation safe. If it is used as the event
in a tokio::select! statement and some other
branch completes first, then the provided buffer may have been
partially written, but future calls to write_all_vectored will
have lost its place in the buffer.
Examples
use write_all_vectored;
use IoSlice;
async
Notes
See the documentation for Write::write_all_vectored from std.
After calling this function, the buffer slices may have
been advanced and should not be reused.