pub trait MessageEncode {
const MAX_SIZE: Result<usize, &'static str>;
// 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§
Sourceconst MAX_SIZE: Result<usize, &'static str>
const MAX_SIZE: Result<usize, &'static str>
Maximum encoded size of the message on the wire.
If MAX_SIZE is Err, that means the message size is unbounded, due to having custom
fields or collections fields without a fixed capacity, such as Vec. The generator will
populate the Err with a message indicating the reason.
The recommended way to use MAX_SIZE in const context is via
max_encoded_size.
Required Methods§
Sourcefn encode<W: PbWrite>(&self, encoder: &mut PbEncoder<W>) -> Result<(), W::Error>
fn encode<W: PbWrite>(&self, encoder: &mut PbEncoder<W>) -> Result<(), W::Error>
Encode this message using the encoder.
Sourcefn compute_size(&self) -> usize
fn compute_size(&self) -> usize
Compute the size of this message on the wire.
Provided Methods§
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.
impl<T: MessageEncode> MessageEncode for &T
Available on crate feature
encode only.