AsyncStreamReader

Trait AsyncStreamReader 

Source
pub trait AsyncStreamReader {
    // Required methods
    fn read_bytes(&mut self, len: usize) -> impl Future<Output = Result<Bytes>>;
    fn read<const L: usize>(&mut self) -> impl Future<Output = Result<[u8; L]>>;

    // Provided methods
    fn read_bytes_exact(
        &mut self,
        len: usize,
    ) -> impl Future<Output = Result<Bytes>> { ... }
    fn read_exact<const L: usize>(
        &mut self,
    ) -> impl Future<Output = Result<[u8; L]>> { ... }
}
Expand description

A non seekable reader, e.g. a network socket.

Required Methods§

Source

fn read_bytes(&mut self, len: usize) -> impl Future<Output = Result<Bytes>>

Read at most len bytes. To read to the end, pass u64::MAX.

returns an empty buffer to indicate EOF.

Source

fn read<const L: usize>(&mut self) -> impl Future<Output = Result<[u8; L]>>

Read a fixed size buffer.

If there are less than L bytes available, an io::ErrorKind::UnexpectedEof error is returned.

Provided Methods§

Source

fn read_bytes_exact( &mut self, len: usize, ) -> impl Future<Output = Result<Bytes>>

Variant of read_bytes that returns an error if less than len bytes are read.

Source

fn read_exact<const L: usize>( &mut self, ) -> impl Future<Output = Result<[u8; L]>>

Variant of read that returns an error if less than L bytes are read.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl AsyncStreamReader for &[u8]

Source§

async fn read_bytes(&mut self, len: usize) -> Result<Bytes>

Source§

async fn read<const L: usize>(&mut self) -> Result<[u8; L]>

Source§

impl AsyncStreamReader for Bytes

Source§

async fn read_bytes(&mut self, len: usize) -> Result<Bytes>

Source§

async fn read<const L: usize>(&mut self) -> Result<[u8; L]>

Source§

impl AsyncStreamReader for BytesMut

Source§

async fn read_bytes(&mut self, len: usize) -> Result<Bytes>

Source§

async fn read<const L: usize>(&mut self) -> Result<[u8; L]>

Source§

impl<T: AsyncSliceReader> AsyncStreamReader for Cursor<T>

Source§

async fn read_bytes(&mut self, len: usize) -> Result<Bytes>

Source§

async fn read<const L: usize>(&mut self) -> Result<[u8; L]>

Source§

impl<T: AsyncStreamReader> AsyncStreamReader for &mut T

Source§

async fn read_bytes(&mut self, len: usize) -> Result<Bytes>

Source§

async fn read<const L: usize>(&mut self) -> Result<[u8; L]>

Implementors§