MessageEncode

Trait MessageEncode 

Source
pub trait MessageEncode {
    const MAX_SIZE: Option<usize>;

    // Required methods
    fn encode<W: PbWrite>(
        &self,
        encoder: &mut PbEncoder<W>,
    ) -> Result<(), W::Error>;
    fn compute_size(&self) -> usize;

    // Provided method
    fn encode_len_delimited<W: PbWrite>(
        &self,
        encoder: &mut PbEncoder<W>,
    ) -> Result<(), W::Error> { ... }
}
Expand description

Protobuf message that can be encoded onto the wire.

Implementations are auto-generated by micropb-gen.

Required Associated Constants§

Source

const MAX_SIZE: Option<usize>

Maximum encoded size of the message on the wire.

If MAX_SIZE is None, that means the message size is unbounded, due to having custom fields or collections fields without a fixed capacity, such as Vec.

Required Methods§

Source

fn encode<W: PbWrite>(&self, encoder: &mut PbEncoder<W>) -> Result<(), W::Error>

Encode this message using the encoder.

Source

fn compute_size(&self) -> usize

Compute the size of this message on the wire.

Provided Methods§

Source

fn encode_len_delimited<W: PbWrite>( &self, encoder: &mut PbEncoder<W>, ) -> Result<(), W::Error>

Encode this message as a length-delimited record, starting with a length prefix.

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<T: MessageEncode> MessageEncode for &T

Available on crate feature encode only.
Source§

const MAX_SIZE: Option<usize> = T::MAX_SIZE

Source§

fn encode<W: PbWrite>(&self, encoder: &mut PbEncoder<W>) -> Result<(), W::Error>

Source§

fn compute_size(&self) -> usize

Source§

fn encode_len_delimited<W: PbWrite>( &self, encoder: &mut PbEncoder<W>, ) -> Result<(), W::Error>

Implementors§