pub trait Reader {
type Error;
// Required method
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>;
}Expand description
Trait for input sources that can provide data to the streaming parser.
Required Associated Types§
Required Methods§
Sourcefn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Self::Error>
Read data into the provided buffer. Returns the number of bytes read, or an error.
§Contract
- A return value of 0 MUST indicate true end of stream
- Implementations MUST NOT return 0 unless no more data will ever be available
- Returning 0 followed by non-zero reads in subsequent calls violates this contract