Trait EncodableSize

Source
pub trait EncodableSize: Encodable<SizeEncoder> {
    // Required method
    fn encoded_size(&self) -> Result<usize, Self::Error>;
}
Expand description

An extension trait for types that can compute the size of their encoded form using a SizeEncoder.

Use this trait to pre-compute buffer sizes or perform validations before full encoding.

This trait is automatically implemented for all types that implement Encodable for SizeEncoder.

§Errors

Returns an error if the Encodable fails to encode.

Required Methods§

Source

fn encoded_size(&self) -> Result<usize, Self::Error>

Computes the size of the encoded representation of self.

§Errors

Returns an error if encoding fails internally during the size estimation.

Implementors§