pub trait Read<'de> {
    type Error: Error + 'static;
    fn fill<'short>(
        &'short mut self,
        want: usize
    ) -> Result<Reference<'de, 'short>, Self::Error>;
fn advance(&mut self, n: usize); fn step_in(&mut self) -> bool { ... }
fn step_out(&mut self) { ... } }
Expand description

Read trait

This is similar to BufRead of standard library, but can define its own error types, and can get a reference with a long enough lifetime to implement zero-copy decode.

Associated Types

Required methods

Returns the available bytes.

The want value is the expected value. If the length of bytes returned is less than this value, zero-copy decoding will not be possible.

Returning empty bytes means EOF.

Advance reader

Provided methods

Step count

This method maybe called when the decode is started to calculate the decode depth. If it returns false, the decode will return a depth limit error.

Step count

This method maybe called when the decode is completed to calculate the decode depth.

Implementations on Foreign Types

Implementors