pub trait BitSize<const LEN: usize>: ByteSize {
const BIT_SIZE: usize = _;
const MIN_BYTE_SIZE: usize = _;
// Provided methods
fn bit_size(&self) -> usize { ... }
fn min_byte_size(&self) -> usize { ... }
}
Expand description
Indicates a size of exactly LEN
bits for the relevant data part of this type.
E.g. a bool
has a BitSize of 1 bit.
Provided Associated Constants§
sourceconst BIT_SIZE: usize = _
const BIT_SIZE: usize = _
The bit size of this type (only the relevant data part, without padding).
§Panics
Panics if MIN_BYTE_SIZE >
[BYTE_SIZE
][Size::BYTE_SIZE],
sourceconst MIN_BYTE_SIZE: usize = _
const MIN_BYTE_SIZE: usize = _
The rounded up byte size for this type.
This is the minimum number of full bytes needed to represent this type.
Basically (LEN + 7) / 8
.
§Panics
Panics if MIN_BYTE_SIZE >
[BYTE_SIZE
][Size::BYTE_SIZE],
Provided Methods§
sourcefn bit_size(&self) -> usize
fn bit_size(&self) -> usize
Returns the bit size of this type (only the relevant data part, without padding).
§Panics
Panics if MIN_BYTE_SIZE >
[BYTE_SIZE
][Size::BYTE_SIZE],
sourcefn min_byte_size(&self) -> usize
fn min_byte_size(&self) -> usize
Returns the rounded up byte size for this type.
This is the minimum number of full bytes needed to represent this type.
Basically (LEN + 7) / 8
.
§Panics
Panics if MIN_BYTE_SIZE >
[BYTE_SIZE
][Size::BYTE_SIZE],