pub trait AsyncWriteWith<'a> {
type WriteFuture: CompletionFuture<Output = Result<usize>>;
type WriteVectoredFuture: CompletionFuture<Output = Result<usize>>;
type FlushFuture: CompletionFuture<Output = Result<()>>;
// Required methods
fn write(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture;
fn write_vectored(
&'a mut self,
bufs: &'a [IoSlice<'a>],
) -> Self::WriteVectoredFuture;
fn flush(&'a mut self) -> Self::FlushFuture;
// Provided method
fn is_write_vectored(&self) -> bool { ... }
}
Expand description
Write bytes to a source asynchronously with a specific lifetime.
Required Associated Types§
Sourcetype WriteFuture: CompletionFuture<Output = Result<usize>>
type WriteFuture: CompletionFuture<Output = Result<usize>>
The future that writes to the source, and outputs the number of bytes written.
Sourcetype WriteVectoredFuture: CompletionFuture<Output = Result<usize>>
type WriteVectoredFuture: CompletionFuture<Output = Result<usize>>
The future that writes a vector of buffers to the source, and outputs the number of bytes
written. If your writer does not have efficient vectored writes, set this to
DefaultWriteVectored<'a, Self>
.
Sourcetype FlushFuture: CompletionFuture<Output = Result<()>>
type FlushFuture: CompletionFuture<Output = Result<()>>
The future that flushes the output stream.
Required Methods§
Sourcefn write(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture
fn write(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture
Write a buffer to the writer, returning how many bytes were written.
Sourcefn write_vectored(
&'a mut self,
bufs: &'a [IoSlice<'a>],
) -> Self::WriteVectoredFuture
fn write_vectored( &'a mut self, bufs: &'a [IoSlice<'a>], ) -> Self::WriteVectoredFuture
Like write
, except that it writes from a slice of buffers.
Data is copied from each buffer in order, with the final buffer read from possibly being
only partially consumed. This method must behave as a call to write
with
the buffers concatenated would.
If your writer does not have efficient vectored writes, call
DefaultWriteVectored::new(self, bufs)
.
Sourcefn flush(&'a mut self) -> Self::FlushFuture
fn flush(&'a mut self) -> Self::FlushFuture
Flush this output stream, ensuring that all intermediately buffered contents reach their destination.
Provided Methods§
Sourcefn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
Determines if this AsyncWrite
r has an efficient write_vectored
implementation.
The default implementation returns false
.