pub trait SizedCodec: Codec {
const LEN_ENCODED: usize;
// Provided methods
fn len_encoded(&self) -> usize { ... }
fn encode_fixed<const N: usize>(&self) -> [u8; N] { ... }
}
Expand description
Trait for types that have a fixed-length encoding
Required Associated Constants§
Sourceconst LEN_ENCODED: usize
const LEN_ENCODED: usize
The encoded length of this value.
Provided Methods§
Sourcefn len_encoded(&self) -> usize
fn len_encoded(&self) -> usize
Returns the encoded length of this value.
Should not be overridden by implementations.
Sourcefn encode_fixed<const N: usize>(&self) -> [u8; N]
fn encode_fixed<const N: usize>(&self) -> [u8; N]
Encodes a value to fixed-size bytes.
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.