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§
Sourcefn poll_read(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut [u8],
) -> Poll<Result<usize>>
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:
bufis empty; or- The source reached its end (the stream is exhausted / EOF).
An implementation SHOULD only generates the following errors:
std::io::ErrorKind::ConnectionResetif the read operation was explicitly truncated by the source.std::io::ErrorKind::NotConnectedif the read operation aborted at any point because lack of communication with the source.