Skip to main content

PreparedLayout

Trait PreparedLayout 

Source
pub trait PreparedLayout {
    type ViewMut<'output>;

    // Required methods
    fn encoded_len(&self) -> usize;
    fn commit_into<'output>(
        self,
        output: &'output mut [u8],
    ) -> Result<(Self::ViewMut<'output>, &'output mut [u8]), OutputTooShortError>;
}
Expand description

A prepared layout encoding that can be committed into an output buffer.

Preparation performs every fallible codec operation. Implementations only check output capacity and copy already-prepared encodings when committed.

Required Associated Types§

Source

type ViewMut<'output>

The mutable view returned over the committed layout bytes.

Required Methods§

Source

fn encoded_len(&self) -> usize

Returns the exact number of output bytes required for this layout.

Source

fn commit_into<'output>( self, output: &'output mut [u8], ) -> Result<(Self::ViewMut<'output>, &'output mut [u8]), OutputTooShortError>

Commits this prepared layout into the leading output bytes.

Extra output bytes are returned as a disjoint suffix. A short output is left unchanged.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§