pub trait Reader<'de> {
    type Error: Error;

    fn pos(&self) -> Option<usize>;
    fn skip(&mut self, n: usize) -> Result<(), Self::Error>;
    fn read_bytes(&mut self, n: usize) -> Result<&'de [u8], Self::Error>;

    fn read(&mut self, buf: &mut [u8]) -> Result<(), Self::Error> { ... }
    fn read_byte(&mut self) -> Result<u8, Self::Error> { ... }
    fn read_array<const N: usize>(&mut self) -> Result<[u8; N], Self::Error> { ... }
    fn with_position(self) -> WithPosition<Self>
    where
        Self: Sized
, { ... } }
Expand description

Trait governing how a source of bytes is read.

This requires the reader to be able to hand out contiguous references to the byte source through Reader::read_bytes.

Required Associated Types

Error type raised by the current reader.

Required Methods

The position of the reader.

Skip over the given number of bytes.

Read a slice out of the current reader.

Provided Methods

Read a slice into the given buffer.

Read a single byte.

Read an array out of the current reader.

Keep an accurate record of the position within the reader.

Implementations on Foreign Types

Implementors