Skip to main content

BitSize

Trait BitSize 

Source
pub trait BitSize {
    const N_BITS: u16;
    const N_BYTES: u8 = _;
    const N_WORDS: u16 = _;

    // Provided method
    fn assert_valid<const N_MAX_BYTES: u8>() { ... }
}

Required Associated Constants§

Source

const N_BITS: u16

Number of bits occupied by the value.

Provided Associated Constants§

Source

const N_BYTES: u8 = _

Number of whole bytes occupied by the value.

Source

const N_WORDS: u16 = _

Number of whole words occupied by the value.

Provided Methods§

Source

fn assert_valid<const N_MAX_BYTES: u8>()

Assert that the number of bytes in the payload is valid.

If the value type is too big, the assertion would fire at compile time.

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 BitSize for i8

Source§

const N_BITS: u16 = 8

Source§

impl BitSize for i16

Source§

const N_BITS: u16 = 16

Source§

impl BitSize for i32

Source§

const N_BITS: u16 = 32

Source§

impl BitSize for i64

Source§

const N_BITS: u16 = 64

Source§

impl BitSize for i128

Source§

const N_BITS: u16 = 128

Source§

impl BitSize for u8

Source§

const N_BITS: u16 = 8

Source§

impl BitSize for u16

Source§

const N_BITS: u16 = 16

Source§

impl BitSize for u32

Source§

const N_BITS: u16 = 32

Source§

impl BitSize for u64

Source§

const N_BITS: u16 = 64

Source§

impl BitSize for u128

Source§

const N_BITS: u16 = 128

Source§

impl<T: BitSize, const N: usize> BitSize for &[T; N]

Source§

impl<T: BitSize, const N: usize> BitSize for [T; N]

Source§

const N_BITS: u16 = <&[T; N]>::N_BITS

Implementors§

Source§

impl BitSize for Entry

Source§

impl BitSize for DecawattHours<u16>

Source§

const N_BITS: u16 = <u16 as BitSize>::N_BITS

Source§

impl BitSize for Percentage<u16>

Source§

const N_BITS: u16 = <u16 as BitSize>::N_BITS

Source§

impl BitSize for Watts<i32>

Source§

const N_BITS: u16 = <i32 as BitSize>::N_BITS

Source§

impl BitSize for Watts<u16>

Source§

const N_BITS: u16 = <u16 as BitSize>::N_BITS