Trait compio_io::AsyncRead

source ·
pub trait AsyncRead {
    // Required method
    async fn read<B: IoBufMut>(&mut self, buf: B) -> BufResult<usize, B>;

    // Provided method
    async fn read_vectored<V: IoVectoredBufMut>(
        &mut self,
        buf: V,
    ) -> BufResult<usize, V> { ... }
}
Expand description

AsyncRead

Async read with a ownership of a buffer

Required Methods§

source

async fn read<B: IoBufMut>(&mut self, buf: B) -> BufResult<usize, B>

Read some bytes from this source into the IoBufMut buffer and return a BufResult, consisting of the buffer and a usize indicating how many bytes were read.

§Caution

Implementor MUST update the buffer init via SetBufInit::set_buf_init after reading, and no further update should be made by caller.

Provided Methods§

source

async fn read_vectored<V: IoVectoredBufMut>( &mut self, buf: V, ) -> BufResult<usize, V>

Like read, except that it reads into a type implements IoVectoredBufMut.

The default implementation will try to read into the buffers in order, and stop whenever the reader returns an error, Ok(0), or a length less than the length of the buf passed in, meaning it’s possible that not all buffer space is filled. If guaranteed full read is desired, it is recommended to use AsyncReadExt::read_vectored_exact instead.

§Caution

Implementor MUST update the buffer init via SetBufInit::set_buf_init after reading.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl AsyncRead for &[u8]

source§

async fn read<T: IoBufMut>(&mut self, buf: T) -> BufResult<usize, T>

source§

async fn read_vectored<T: IoVectoredBufMut>( &mut self, buf: T, ) -> BufResult<usize, T>

source§

impl<A: AsyncRead + ?Sized> AsyncRead for &mut A

source§

async fn read<T: IoBufMut>(&mut self, buf: T) -> BufResult<usize, T>

source§

async fn read_vectored<T: IoVectoredBufMut>( &mut self, buf: T, ) -> BufResult<usize, T>

source§

impl<A: AsyncReadAt> AsyncRead for Cursor<A>

source§

async fn read<T: IoBufMut>(&mut self, buf: T) -> BufResult<usize, T>

source§

async fn read_vectored<T: IoVectoredBufMut>( &mut self, buf: T, ) -> BufResult<usize, T>

source§

impl<R: AsyncRead + ?Sized> AsyncRead for Box<R>

source§

async fn read<T: IoBufMut>(&mut self, buf: T) -> BufResult<usize, T>

source§

async fn read_vectored<T: IoVectoredBufMut>( &mut self, buf: T, ) -> BufResult<usize, T>

Implementors§