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;
}
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.

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.

Implementors§

Source§

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

Source§

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

Source§

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