codeq/
fixed_size.rs

1/// Trait for types that have a fixed, known size when encoded.
2///
3/// This trait is implemented by types whose encoded representation always
4/// has the same size, regardless of their value. For example:
5/// - Primitive integers (u8, i32, u64, etc.)
6/// - Fixed-size structs containing only fixed-size fields
7/// - Arrays or tuples of fixed-size types
8///
9/// This information can be used to:
10/// - Pre-allocate buffers of the correct size
11/// - Perform bounds checking before encoding/decoding
12/// - Calculate storage requirements statically
13pub trait FixedSize {
14    /// Returns the size in bytes that this type will occupy when encoded.
15    ///
16    /// This size must be constant for all instances of the type.
17    fn encoded_size() -> usize;
18}