Skip to main content

DecodeSource

Trait DecodeSource 

Source
pub trait DecodeSource {
    // Required method
    fn read_exact(&mut self, out: &mut [u8]) -> Result<(), CodecError>;

    // Provided method
    fn remaining_len(&self) -> Option<usize> { ... }
}
Expand description

Source for canonical encoded bytes.

Required Methods§

Source

fn read_exact(&mut self, out: &mut [u8]) -> Result<(), CodecError>

Reads exactly enough bytes to fill out or returns an error.

Provided Methods§

Source

fn remaining_len(&self) -> Option<usize>

Returns the unread byte count when the source can know it cheaply.

Streaming sources may return None. Slice-backed sources return Some(_), allowing decoders to reject impossible length prefixes before allocating.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§