Trait StreamingReader

Source
pub trait StreamingReader {
    type Error;

    // Required methods
    fn read_bytes(&mut self, buf: &mut [u8]) -> Result<(), Self::Error>;
    fn share_bytes(&mut self, len: usize) -> Result<&[u8], Self::Error>;
}
Expand description

Reader backend trait

Required Associated Types§

Source

type Error

The kind of Error the implementation produces

Required Methods§

Source

fn read_bytes(&mut self, buf: &mut [u8]) -> Result<(), Self::Error>

Read bytes from the underlying data source into the provided buf. Should return an error if insufficient bytes are available to fully fill buf.

Source

fn share_bytes(&mut self, len: usize) -> Result<&[u8], Self::Error>

Expose an aliased view of a subset of the underlying data as immutable bytes.

The implementer must ensure that the view of bytes returned does not overlap with the region of bytes that it allows itself to mutate at any further point.

Implementors§