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, BoxError>>;

    // Provided method
    fn poll_read_vectored(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>,
        bufs: &mut [IoSliceMut<'_>],
    ) -> Poll<Result<usize, BoxError>> { ... }
}
Expand description

Trait for async reading operations.

This trait provides an interface for asynchronously reading bytes from a source.

Required Methods§

Source

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

Attempts to read bytes into a buffer.

§Errors

Returns an error if the read operation fails.

Provided Methods§

Source

fn poll_read_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &mut [IoSliceMut<'_>], ) -> Poll<Result<usize, BoxError>>

Attempts to read bytes into multiple buffers (vectored I/O).

§Errors

Returns an error if the read operation fails.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<P> AsyncRead for Pin<P>
where P: DerefMut, P::Target: AsyncRead,

Source§

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

Source§

impl<T: ?Sized + AsyncRead + Unpin> AsyncRead for &mut T

Source§

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

Source§

impl<T: ?Sized + AsyncRead + Unpin> AsyncRead for Box<T>

Source§

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

Implementors§