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§
Required Methods§
Sourcefn read_bytes(&mut self, buf: &mut [u8]) -> Result<(), Self::Error>
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
.
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.