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.