Trait NestedDecodeInput

Source
pub trait NestedDecodeInput {
    // Required methods
    fn remaining_len(&mut self) -> usize;
    fn read_into(&mut self, into: &mut [u8]) -> Result<(), DecodeError>;
    fn read_into_or_exit<ExitCtx: Clone>(
        &mut self,
        into: &mut [u8],
        c: ExitCtx,
        exit: fn(ExitCtx, DecodeError) -> !,
    );
    fn read_slice(&mut self, length: usize) -> Result<&[u8], DecodeError>;
    fn read_slice_or_exit<ExitCtx: Clone>(
        &mut self,
        length: usize,
        c: ExitCtx,
        exit: fn(ExitCtx, DecodeError) -> !,
    ) -> &[u8];
    fn flush(&mut self) -> &[u8];

    // Provided methods
    fn empty(&mut self) -> bool { ... }
    fn read_byte(&mut self) -> Result<u8, DecodeError> { ... }
    fn read_byte_or_exit<ExitCtx: Clone>(
        &mut self,
        c: ExitCtx,
        exit: fn(ExitCtx, DecodeError) -> !,
    ) -> u8 { ... }
}
Expand description

Trait that allows reading of data into a slice.

Required Methods§

Source

fn remaining_len(&mut self) -> usize

The remaining length of the input data.

Source

fn read_into(&mut self, into: &mut [u8]) -> Result<(), DecodeError>

Read the exact number of bytes required to fill the given buffer.

Source

fn read_into_or_exit<ExitCtx: Clone>( &mut self, into: &mut [u8], c: ExitCtx, exit: fn(ExitCtx, DecodeError) -> !, )

Read the exact number of bytes required to fill the given buffer. Exit early if there are not enough bytes to fill the result.

Source

fn read_slice(&mut self, length: usize) -> Result<&[u8], DecodeError>

Read the exact number of bytes required to fill the given buffer.

Source

fn read_slice_or_exit<ExitCtx: Clone>( &mut self, length: usize, c: ExitCtx, exit: fn(ExitCtx, DecodeError) -> !, ) -> &[u8]

Read the exact number of bytes required to fill the given buffer. Exit directly if the input contains too few bytes.

Source

fn flush(&mut self) -> &[u8]

Clears the input buffer and returns all remaining bytes.

Provided Methods§

Source

fn empty(&mut self) -> bool

Source

fn read_byte(&mut self) -> Result<u8, DecodeError>

Read a single byte from the input.

Source

fn read_byte_or_exit<ExitCtx: Clone>( &mut self, c: ExitCtx, exit: fn(ExitCtx, DecodeError) -> !, ) -> u8

Read a single byte from the input.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'a> NestedDecodeInput for &'a [u8]

Source§

fn remaining_len(&mut self) -> usize

Source§

fn read_into(&mut self, into: &mut [u8]) -> Result<(), DecodeError>

Source§

fn read_into_or_exit<ExitCtx: Clone>( &mut self, into: &mut [u8], c: ExitCtx, exit: fn(ExitCtx, DecodeError) -> !, )

Source§

fn read_slice(&mut self, length: usize) -> Result<&[u8], DecodeError>

Source§

fn read_slice_or_exit<ExitCtx: Clone>( &mut self, length: usize, c: ExitCtx, exit: fn(ExitCtx, DecodeError) -> !, ) -> &[u8]

Source§

fn flush(&mut self) -> &[u8]

Implementors§