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 version of std::io::Read.

The poll method must be called with a pinned Self and a Context. It returns Poll::Ready(Ok(n)) when n bytes have been written into buf, or Poll::Pending when no bytes are available yet (the waker will be called when data arrives).

Required Methods§

Source

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

Attempt to read bytes into buf.

On success returns Poll::Ready(Ok(n)) where n is the number of bytes read. n == 0 signals EOF. Returns Poll::Pending and arranges for the waker to be called on the next read-readiness event.

Implementors§