pub trait Write: Io {
    type WriteFuture<'a>: Future<Output = Result<usize, Self::Error>>
    where
        Self: 'a
; type FlushFuture<'a>: Future<Output = Result<(), Self::Error>>
    where
        Self: 'a
; fn write<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture<'a>; fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a>; fn write_all<'a>(
        &'a mut self,
        buf: &'a [u8]
    ) -> impl Future<Output = Result<(), Self::Error>> { ... } }
Available on crate feature async only.
Expand description

Async writer.

Semantics are the same as std::io::Write, check its documentation for details.

Required Associated Types

Future returned by write.

Future returned by flush.

Required Methods

Write a buffer into this writer, returning how many bytes were written.

Flush this output stream, ensuring that all intermediately buffered contents reach their destination.

Provided Methods

Write an entire buffer into this writer.

Implementations on Foreign Types

Write is implemented for &mut [u8] by copying into the slice, overwriting its data.

Note that writing updates the slice to point to the yet unwritten part. The slice will be empty when it has been completely overwritten.

If the number of bytes to be written exceeds the size of the slice, write operations will return short writes: ultimately, Ok(0); in this situation, write_all returns an error of kind ErrorKind::WriteZero.

Implementors