Skip to main content

ReadSlice

Trait ReadSlice 

Source
pub trait ReadSlice<'de>: Read {
    // Required method
    fn read_slice<'a>(
        &'a mut self,
        len: usize,
    ) -> Result<Reference<'de, 'a, [u8]>, Error>;
}
Expand description

Extends the Read trait by allowing to read slices directly by borrowing bytes.

Used to allow zero-copy reading.

Required Methods§

Source

fn read_slice<'a>( &'a mut self, len: usize, ) -> Result<Reference<'de, 'a, [u8]>, Error>

Reads the exact number of bytes from the underlying byte-array.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<'de, R> ReadSlice<'de> for ReadReader<R>
where R: Read,

Source§

impl<'de, T> ReadSlice<'de> for ReadRefReader<'de, T>
where T: AsRef<[u8]> + ?Sized,