Trait EncodeSize

Source
pub trait EncodeSize {
    // Provided methods
    fn max_encoding_size(&self) -> usize { ... }
    fn encoding_size(&self) -> usize { ... }
}

Provided Methods§

Source

fn max_encoding_size(&self) -> usize

Return the max number of bytes needed to encode this value

Calculate the maximum size by summing up the maximum length of each field. If a field type has a maximum length, use it, otherwise use the actual length of the data in that field.

When packaging data, by pre-estimating this value to effectively avoid spending extra resources to calculate the actual encoded size.

Source

fn encoding_size(&self) -> usize

Return the exact number of bytes needed to encode this value

Implementors§