Skip to main content

AsyncRead

Trait AsyncRead 

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

Async read half of a byte stream.

Mirrors std::io::Read but returns Poll for non-blocking use with the executor.

§Contract

  • Poll::Ready(Ok(0)) means EOF — the peer closed its write half.
  • Poll::Ready(Ok(n)) means n bytes were read into buf[..n].
  • Poll::Pending means no data is available yet — the waker will be notified when the stream becomes readable.
  • Poll::Ready(Err(e)) is a fatal IO error.

Required Methods§

Source

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

Attempt to read from the stream into buf.

Implementors§