Skip to main content

FixedBitLen

Trait FixedBitLen 

Source
pub trait FixedBitLen {
    const BIT_LEN: u32;
}
Expand description

A message whose encoded length is a compile-time constant — i.e. it has no variable-length (count-driven Vec) field. The derive implements this only for fixed messages; it sizes a fixed byte region when the message is embedded as a field in another message (its contribution to the parent’s width). A count-bearing message implements BitDecode/BitEncode but not this. Bits leaves also implement it (their BIT_LEN is Bits::BITS), so a field’s width is computed uniformly whether it’s a leaf or a nested message.

Required Associated Constants§

Source

const BIT_LEN: u32

Total encoded width of the message in bits — the sum of its fields’ widths.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl FixedBitLen for Ipv4Addr

Available on crate feature std only.
Source§

const BIT_LEN: u32 = 32

Source§

impl FixedBitLen for Ipv6Addr

Available on crate feature std only.
Source§

const BIT_LEN: u32 = 128

Source§

impl FixedBitLen for bool

Source§

const BIT_LEN: u32 = <bool as Bits>::BITS

Source§

impl FixedBitLen for u8

Source§

const BIT_LEN: u32 = <u8 as Bits>::BITS

Source§

impl FixedBitLen for u16

Source§

const BIT_LEN: u32 = <u16 as Bits>::BITS

Source§

impl FixedBitLen for u32

Source§

const BIT_LEN: u32 = <u32 as Bits>::BITS

Source§

impl FixedBitLen for u64

Source§

const BIT_LEN: u32 = <u64 as Bits>::BITS

Source§

impl FixedBitLen for u128

Source§

const BIT_LEN: u32 = <u128 as Bits>::BITS

Implementors§

Source§

impl<T, const N: usize> FixedBitLen for UInt<T, N>
where UInt<T, N>: Bits,

Source§

const BIT_LEN: u32 = <Self as Bits>::BITS

Source§

impl<T: Bits> FixedBitLen for WireLen<T>

A WireLen<T> occupies exactly T’s width, so it stays a fixed-width field (a DNS header with WireLen<u16> counts is still 12 bytes).

Source§

const BIT_LEN: u32 = <T as Bits>::BITS