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

Reads bytes from a source.

Required Methods§

Source

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

Attempt to read from the source into buf.

Generally, an implementation will perform a copy.

On success, it returns Ok(num_bytes_read), that is the length of bytes written into buf.

It returns 0 if and only if:

  • buf is empty; or
  • The source reached its end (the stream is exhausted / EOF).

An implementation SHOULD only generates the following errors:

Implementations on Foreign Types§

Source§

impl AsyncRead for &[u8]

Source§

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

Implementors§