FixedSize

Trait FixedSize 

Source
pub trait FixedSize {
    // Required method
    fn encoded_size() -> usize;
}
Expand description

Trait for types that have a fixed, known size when encoded.

This trait is implemented by types whose encoded representation always has the same size, regardless of their value. For example:

  • Primitive integers (u8, i32, u64, etc.)
  • Fixed-size structs containing only fixed-size fields
  • Arrays or tuples of fixed-size types

This information can be used to:

  • Pre-allocate buffers of the correct size
  • Perform bounds checking before encoding/decoding
  • Calculate storage requirements statically

Required Methods§

Source

fn encoded_size() -> usize

Returns the size in bytes that this type will occupy when encoded.

This size must be constant for all instances of the type.

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.

Implementations on Foreign Types§

Source§

impl FixedSize for bool

Source§

impl FixedSize for u8

Source§

impl FixedSize for u32

Source§

impl FixedSize for u64

Source§

impl FixedSize for ()

Source§

impl<T: FixedSize> FixedSize for Option<T>

Implementors§

Source§

impl<C> FixedSize for Segment<C>
where C: CodeqConfig,

Source§

impl<C, T> FixedSize for WithChecksum<C, T>
where C: CodeqConfig, T: FixedSize,