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 write half of a byte stream.
Mirrors std::io::Write but returns Poll for non-blocking use.
§Contract
Poll::Ready(Ok(n))meansnbytes frombuf[..n]were written.Poll::Pendingmeans the write buffer is full — the waker will be notified when the stream becomes writable.poll_flushensures all buffered data reaches the OS send buffer.poll_shutdownsignals that no more data will be written (TCP FIN).
Required Methods§
Sourcefn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize>>
fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize>>
Attempt to write buf to the stream.