Skip to main content

EncodePlan

Trait EncodePlan 

Source
pub trait EncodePlan {
    // Required methods
    fn encoded_len(&self) -> usize;
    fn write_into(&self, output: &mut [u8]);
}
Expand description

A completed, infallible encoding operation.

Implementations perform all fallible work while they are created. write_into therefore only copies already-prepared bytes into an exactly-sized output slice.

Required Methods§

Source

fn encoded_len(&self) -> usize

Returns the exact number of bytes written by Self::write_into.

Source

fn write_into(&self, output: &mut [u8])

Writes this plan into output.

output must have length Self::encoded_len. Passing another length is a contract violation and may panic; implementations must not silently succeed without writing the complete encoding.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl EncodePlan for &[u8]

Source§

fn encoded_len(&self) -> usize

Source§

fn write_into(&self, output: &mut [u8])

Source§

impl<const N: usize> EncodePlan for [u8; N]

Source§

fn encoded_len(&self) -> usize

Source§

fn write_into(&self, output: &mut [u8])

Implementors§