Trait AsyncWrite

Source
pub trait AsyncWrite {
    type Error;

    // Required methods
    fn poll_write(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>,
        buf: &[u8],
    ) -> Poll<Result<usize, Self::Error>>;
    fn poll_flush(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>,
    ) -> Poll<Result<(), Self::Error>>;

    // Provided method
    fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> WriteAll<'a, Self> 
       where Self: Unpin { ... }
}
Available on crate feature io only.

Required Associated Types§

Required Methods§

Source

fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize, Self::Error>>

Source

fn poll_flush( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Self::Error>>

Provided Methods§

Source

fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> WriteAll<'a, Self>
where Self: Unpin,

Attempts to write an entire buffer into this writer.

Equivalent to:

async fn write_all(&mut self, buf: &[u8]) -> io::Result<()>;

This method will continuously call write until there is no more data to be written. This method will not return until the entire buffer has been successfully written or such an error occurs. The first error generated from this method will be returned.

§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 will start over from the beginning of the buffer.

§Errors

This function will return the first error that write returns. write: AsyncWrite::write

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl AsyncWrite for &mut [u8]

Source§

type Error = Void

Source§

fn poll_write( self: Pin<&mut Self>, _cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize, Self::Error>>

Source§

fn poll_flush( self: Pin<&mut Self>, _cx: &mut Context<'_>, ) -> Poll<Result<(), Self::Error>>

Source§

impl<P> AsyncWrite for Pin<P>
where P: DerefMut + Unpin, P::Target: AsyncWrite,

Source§

type Error = <<P as Deref>::Target as AsyncWrite>::Error

Source§

fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize, Self::Error>>

Source§

fn poll_flush( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Self::Error>>

Source§

impl<T: ?Sized + AsyncWrite + Unpin> AsyncWrite for &mut T

Source§

type Error = <T as AsyncWrite>::Error

Source§

fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize, Self::Error>>

Source§

fn poll_flush( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Self::Error>>

Implementors§

Source§

impl<T> AsyncWrite for Writer<T>
where T: Sink<u8> + Unpin,

Source§

type Error = <T as Sink<u8>>::Error