Skip to main content

Encode

Trait Encode 

Source
pub trait Encode: Encoded {
    // Required methods
    fn encoded_len(&self) -> usize;
    fn try_write<E>(
        self,
        emit: impl FnMut(&[u8]) -> Result<(), E>,
    ) -> Result<(), E>;

    // Provided method
    fn encode(self, out: &mut impl Writer)
       where Self: Sized { ... }
}
Expand description

A generated field value with an exact encoded length.

Required Methods§

Source

fn encoded_len(&self) -> usize

Source

fn try_write<E>(self, emit: impl FnMut(&[u8]) -> Result<(), E>) -> Result<(), E>

Stops at the first rejected fragment and preserves its exact error.

Provided Methods§

Source

fn encode(self, out: &mut impl Writer)
where Self: Sized,

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl Encode for Encoder<'_>

Source§

impl<T: Bytes> Encode for Value<T>