Trait Reader

Source
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§

Source

type Error

The error type returned by read operations

Required Methods§

Source

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

Implementors§