Trait cbor4ii::core::dec::Read

source ·
pub trait Read<'de> {
    type Error: Error + 'static;

    // Required methods
    fn fill<'short>(
        &'short mut self,
        want: usize
    ) -> Result<Reference<'de, 'short>, Self::Error>;
    fn advance(&mut self, n: usize);

    // Provided methods
    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.

Required Associated Types§

source

type Error: Error + 'static

Required Methods§

source

fn fill<'short>( &'short mut self, want: usize ) -> Result<Reference<'de, 'short>, Self::Error>

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.

source

fn advance(&mut self, n: usize)

Advance reader

Provided Methods§

source

fn step_in(&mut self) -> bool

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.

source

fn step_out(&mut self)

Step count

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

Implementations on Foreign Types§

source§

impl<'a, 'de, T: Read<'de>> Read<'de> for &'a mut T

§

type Error = <T as Read<'de>>::Error

source§

fn fill<'short>( &'short mut self, want: usize ) -> Result<Reference<'de, 'short>, Self::Error>

source§

fn advance(&mut self, n: usize)

source§

fn step_in(&mut self) -> bool

source§

fn step_out(&mut self)

Implementors§

source§

impl<'de> Read<'de> for SliceReader<'de>

source§

impl<'de, R: BufRead> Read<'de> for IoReader<R>

§

type Error = Error