pub trait EncodeSize {
// Provided methods
fn max_encoding_size(&self) -> usize { ... }
fn encoding_size(&self) -> usize { ... }
}
Provided Methods§
Sourcefn max_encoding_size(&self) -> usize
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.
Sourcefn encoding_size(&self) -> usize
fn encoding_size(&self) -> usize
Return the exact number of bytes needed to encode this value