pub trait EncodeSize {
// Required method
fn encode_size(&self) -> usize;
// Provided method
fn encode_inline_size(&self) -> usize { ... }
}Expand description
Trait for types that can provide their encoded size in bytes.
This must be implemented by all encodable types. For types implementing FixedSize, this trait is implemented automatically. For variable-size types, this requires calculating the size based on the value.
Required Methods§
Sourcefn encode_size(&self) -> usize
fn encode_size(&self) -> usize
Returns the encoded size of this value (in bytes).
Provided Methods§
Sourcefn encode_inline_size(&self) -> usize
fn encode_inline_size(&self) -> usize
Returns the encoded size excluding bytes passed to BufsMut::push
during Write::write_bufs. Used to size the working buffer for inline
writes. Override alongside Write::write_bufs for types where large
Bytes fields go via push; failing to do so will over-allocate.