Trait ZeroCopyReader

Source
pub trait ZeroCopyReader<'a> {
    // Required methods
    fn try_read(&mut self, size: usize) -> Result<BytesCow<'a>, Error>;
    fn as_std(&mut self) -> impl Read;

    // Provided methods
    fn take(self, limit: usize) -> Take<Self>
       where Self: Sized { ... }
    fn try_read_to_end(&mut self) -> Result<BytesCow<'a>, Error> { ... }
}
Expand description

A trait for zero-copy readers.

Required Methods§

Source

fn try_read(&mut self, size: usize) -> Result<BytesCow<'a>, Error>

Attempts to read a specified number of bytes from the reader without copying.

This function does not guarantee that no copying will occur. Some implementations can’t avoid copying.

Source

fn as_std(&mut self) -> impl Read

Returns a standard io::Read interface for the reader.

Provided Methods§

Source

fn take(self, limit: usize) -> Take<Self>
where Self: Sized,

Limits the number of bytes that can be read from the reader.

Source

fn try_read_to_end(&mut self) -> Result<BytesCow<'a>, Error>

Reads all remaining bytes from the reader.

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<'a, T: ZeroCopyReader<'a>> ZeroCopyReader<'a> for &mut T

Source§

fn try_read(&mut self, size: usize) -> Result<BytesCow<'a>, Error>

Source§

fn as_std(&mut self) -> impl Read

Implementors§

Source§

impl<'a> ZeroCopyReader<'a> for Slice<'a>

Source§

impl<'a, B: Buf> ZeroCopyReader<'a> for BytesBuf<B>

Source§

impl<'a, R> ZeroCopyReader<'a> for Take<R>
where R: ZeroCopyReader<'a>,

Source§

impl<'a, R: Read> ZeroCopyReader<'a> for IoRead<R>