Skip to main content

AsyncRead

Trait AsyncRead 

Source
pub trait AsyncRead {
    type Error;

    // Required method
    fn read<'a>(
        &'a mut self,
        buf: &'a mut [u8],
    ) -> impl Future<Output = Result<usize, Self::Error>>;
}
Expand description

A stream that can be read from asynchronously.

Required Associated Types§

Source

type Error

The error returned by read.

Required Methods§

Source

fn read<'a>( &'a mut self, buf: &'a mut [u8], ) -> impl Future<Output = Result<usize, Self::Error>>

Reads into a given buffer, returns the number of read bytes.

Returns 0 if the stream is closed (or if the buffer is empty).

§Errors

Returns an error if reading fails.

§Cancel safety

Implementations in this crate are cancel safe.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<const FDS: usize> AsyncRead for BorrowedReadHalf<'_, '_, FDS>

Source§

impl<const FDS: usize> AsyncRead for TcpStream<'_, FDS>

Source§

impl<const FDS: usize> AsyncRead for UnixStream<'_, FDS>