Interface EncoderBitMaskings<ValueType>

Specifies which values to write in which bits when writing an unsigned int.

interface EncoderBitMaskings<ValueType> {
    bits: number[];
    values: ValueType[];
}

Type Parameters

  • ValueType extends number | bigint

Hierarchy

  • BitMaskings
    • EncoderBitMaskings

Properties

Properties

bits: number[]

List of bit masks to use. Masks must add up to the total bit size of the associated data type, such as:

// ok
uint32({ bits: [1, 31] }); // 1 + 31 == 32
uint64({ bits: [2, 2, 60] }); // 2 + 2 + 60 == 64

// exception!
uint32({ bits: [1, 9] }); // 1 + 9 != 32
uint64({ bits: [2, 2, 64] }); // 2 + 2 + 64 != 64
values: ValueType[]

List of values to write for each bit mask. Values must fit within the bit restriction they correspond with, such as:

// ok
uint32({ bits: [1, …], values: [1, …] }); // 1 fits in 1 bit
uint64({ bits: [4, …], values: [10, …] }); // 10 fits in 4 bits

// exception!
uint32({ bits: [1, …], values: [2, …] }); // 2 does NOT fit in 1 bit
uint64({ bits: [2, …], values: [10, …] }); // 10 does NOT fit in 2 bits