Skip to main content

AsyncWriteWith

Trait AsyncWriteWith 

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

Source

type WriteFuture: CompletionFuture<Output = Result<usize>>

The future that writes to the source, and outputs the number of bytes written.

Source

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

Source

type FlushFuture: CompletionFuture<Output = Result<()>>

The future that flushes the output stream.

Required Methods§

Source

fn write(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture

Write a buffer to the writer, returning how many bytes were written.

Source

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

Source

fn flush(&'a mut self) -> Self::FlushFuture

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

Provided Methods§

Source

fn is_write_vectored(&self) -> bool

Determines if this AsyncWriter has an efficient write_vectored implementation.

The default implementation returns false.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<'a, 's> AsyncWriteWith<'a> for &'s mut [u8]

Source§

type WriteFuture = WriteSlice<'a, 's>

Source§

type WriteVectoredFuture = WriteVectoredSlice<'a, 's>

Source§

type FlushFuture = Ready<Result<(), Error>>

Source§

fn write(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture

Source§

fn write_vectored( &'a mut self, bufs: &'a [IoSlice<'a>], ) -> Self::WriteVectoredFuture

Source§

fn is_write_vectored(&self) -> bool

Source§

fn flush(&'a mut self) -> Self::FlushFuture

Source§

impl<'a, W: AsyncWriteWith<'a> + ?Sized> AsyncWriteWith<'a> for &mut W

Source§

type WriteFuture = <W as AsyncWriteWith<'a>>::WriteFuture

Source§

type WriteVectoredFuture = <W as AsyncWriteWith<'a>>::WriteVectoredFuture

Source§

type FlushFuture = <W as AsyncWriteWith<'a>>::FlushFuture

Source§

fn write(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture

Source§

fn write_vectored( &'a mut self, bufs: &'a [IoSlice<'a>], ) -> Self::WriteVectoredFuture

Source§

fn is_write_vectored(&self) -> bool

Source§

fn flush(&'a mut self) -> Self::FlushFuture

Source§

impl<'a, W: AsyncWriteWith<'a> + ?Sized> AsyncWriteWith<'a> for Box<W>

Source§

type WriteFuture = <W as AsyncWriteWith<'a>>::WriteFuture

Source§

type WriteVectoredFuture = <W as AsyncWriteWith<'a>>::WriteVectoredFuture

Source§

type FlushFuture = <W as AsyncWriteWith<'a>>::FlushFuture

Source§

fn write(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture

Source§

fn write_vectored( &'a mut self, bufs: &'a [IoSlice<'a>], ) -> Self::WriteVectoredFuture

Source§

fn is_write_vectored(&self) -> bool

Source§

fn flush(&'a mut self) -> Self::FlushFuture

Source§

impl<'a> AsyncWriteWith<'a> for &Sink

Source§

type WriteFuture = Ready<Result<usize, Error>>

Source§

type WriteVectoredFuture = Ready<Result<usize, Error>>

Source§

type FlushFuture = Ready<Result<(), Error>>

Source§

fn write(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture

Source§

fn write_vectored( &'a mut self, bufs: &'a [IoSlice<'a>], ) -> Self::WriteVectoredFuture

Source§

fn is_write_vectored(&self) -> bool

Source§

fn flush(&'a mut self) -> Self::FlushFuture

Source§

impl<'a> AsyncWriteWith<'a> for Sink

Source§

type WriteFuture = Ready<Result<usize, Error>>

Source§

type WriteVectoredFuture = Ready<Result<usize, Error>>

Source§

type FlushFuture = Ready<Result<(), Error>>

Source§

fn write(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture

Source§

fn write_vectored( &'a mut self, bufs: &'a [IoSlice<'a>], ) -> Self::WriteVectoredFuture

Source§

fn is_write_vectored(&self) -> bool

Source§

fn flush(&'a mut self) -> Self::FlushFuture

Source§

impl<'a> AsyncWriteWith<'a> for Vec<u8>

Source§

type WriteFuture = WriteVec<'a>

Source§

type WriteVectoredFuture = WriteVectoredVec<'a>

Source§

type FlushFuture = Ready<Result<(), Error>>

Source§

fn write(&'a mut self, buf: &'a [u8]) -> Self::WriteFuture

Source§

fn write_vectored( &'a mut self, bufs: &'a [IoSlice<'a>], ) -> Self::WriteVectoredFuture

Source§

fn is_write_vectored(&self) -> bool

Source§

fn flush(&'a mut self) -> Self::FlushFuture

Implementors§