Trait MaxEncodedLen
pub trait MaxEncodedLen: Encode {
// Required method
fn max_encoded_len() -> usize;
}
Expand description
Items implementing MaxEncodedLen
have a statically known maximum encoded size.
Some containers, such as BoundedVec
, have enforced size limits and this trait
can be implemented accurately. Other containers, such as StorageMap
, do not have enforced size
limits. For those containers, it is necessary to make a documented assumption about the maximum
usage, and compute the max encoded length based on that assumption.
Required Methods§
fn max_encoded_len() -> usize
fn max_encoded_len() -> usize
Upper bound, in bytes, of the maximum encoded size of this item.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.