Trait constriction::BitArray [−][src]
pub unsafe trait BitArray: PrimInt + Unsigned + WrappingAdd + WrappingSub + LowerHex + UpperHex + Binary + Default + Copy + Display + Debug + Eq + Hash + 'static { type NonZero: NonZeroBitArray<Base = Self>; const BITS: usize; fn into_nonzero(self) -> Option<Self::NonZero> { ... } unsafe fn into_nonzero_unchecked(self) -> Self::NonZero { ... } }
Expand description
A trait for bit strings of fixed (and usually small) length.
Short fixed-length bit strings are fundamental building blocks of efficient entropy coding algorithms. They are currently used for the following purposes:
- to represent the smallest unit of compressed data (see [
Code::Word
]); - to represent probabilities in fixed point arithmetic (see
[
EntropyModel::Probability
]); and - the internal state of entropy coders (see [
Code::State
]) is typically comprised of one or moreBitArray
s, although this is not a requirement.
This trait is implemented on all primitive unsigned integer types. It is not recommended
to implement this trait for custom types since coders will assume, for performance
considerations, that BitArray
s can be represented and manipulated efficiently in
hardware.
Safety
This trait is marked unsafe
so that entropy coders may rely on the assumption that all
BitArray
s have precisely the same behavior as builtin unsigned integer types, and that
BitArray::BITS
has the correct value.
Associated Types
type NonZero: NonZeroBitArray<Base = Self>
[src]
Associated Constants
const BITS: usize
[src]
Expand description
The (fixed) length of the BitArray
in bits.
Defaults to 8 * core::mem::size_of::<Self>()
, which is suitable for all
primitive unsigned integers.
This could arguably be called LEN
instead, but that may be confusing since
“lengths” are typically not measured in bits in the Rust ecosystem.
Provided methods
fn into_nonzero(self) -> Option<Self::NonZero>
[src]
unsafe fn into_nonzero_unchecked(self) -> Self::NonZero
[src]
Expand description
Safety
The provided value must be nonzero.
Implementations on Foreign Types
impl BitArray for u16
[src]
impl BitArray for u16
[src]type NonZero = NonZeroU16
impl BitArray for u32
[src]
impl BitArray for u32
[src]type NonZero = NonZeroU32
impl BitArray for u64
[src]
impl BitArray for u64
[src]type NonZero = NonZeroU64
impl BitArray for u128
[src]
impl BitArray for u128
[src]type NonZero = NonZeroU128
impl BitArray for usize
[src]
impl BitArray for usize
[src]