Skip to main content

AsyncWrite

Trait AsyncWrite 

Source
pub trait AsyncWrite {
    // Required methods
    fn poll_write(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>,
        buf: &[u8],
    ) -> Poll<Result<usize>>;
    fn poll_flush(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>,
    ) -> Poll<Result<()>>;
    fn poll_shutdown(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>,
    ) -> Poll<Result<()>>;
}
Expand description

Async version of std::io::Write.

All three poll methods follow the same contract: Poll::Ready(Ok(...)) on success, Poll::Pending when the underlying resource is not ready (with the waker arranged to fire when it becomes ready).

Required Methods§

Source

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

Attempt to write bytes from buf into the sink.

Returns the number of bytes written. May be less than buf.len().

Source

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

Flush any internal buffers to the OS.

For kernel-backed sockets this is a no-op that returns Ready(Ok(())).

Source

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

Initiate a half-close: shut down the write side of the connection.

Implementors§