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))meansnbytes were read intobuf[..n].Poll::Pendingmeans no data is available yet — the waker will be notified when the stream becomes readable.Poll::Ready(Err(e))is a fatal IO error.