Provides a set of functions for reading and writing packed integers from a slice of bytes.
Functions
fn get(bytes: []const u8, index: usize, bit_offset: u7) Int
Retrieves the integer at
index
from the packed data beginning atbit_offset
…Retrieves the integer at
index
from the packed data beginning atbit_offset
withinbytes
.fn set(bytes: []u8, index: usize, bit_offset: u3, int: Int) void
Sets the integer at
index
toval
within the packed data beginning at `bit_o…Sets the integer at
index
toval
within the packed data beginning atbit_offset
intobytes
.fn slice(bytes: []u8, bit_offset: u3, start: usize, end: usize) PackedIntSliceEndian(Int, endian)
Provides a PackedIntSlice of the packed integers in
bytes
(which begins at `bi…Provides a PackedIntSlice of the packed integers in
bytes
(which begins atbit_offset
) from the element specified bystart
to the element specified byend
.fn sliceCast(bytes: []u8, comptime NewInt: type, comptime new_endian: Endian, bit_offset: u3, old_len: usize) PackedIntSliceEndian(NewInt, new_endian)
Recasts a packed slice to a version with elements of type
NewInt
and endiannes…Recasts a packed slice to a version with elements of type
NewInt
and endiannessnew_endian
. Slice will begin atbit_offset
withinbytes
and the new length will be automatically calculated fromold_len
using the sizes of the current integer type andNewInt
.