fn readVarPackedInt(comptime T: type, bytes: []const u8, bit_offset: usize, bit_count: usize, endian: std.builtin.Endian, signedness: std.builtin.Signedness) T

Loads an integer from packed memory with provided bit_count, bit_offset, and signedness. Asserts that T is large enough to store the read value.

Example: const T = packed struct(u16){ a: u3, b: u7, c: u6 }; var st = T{ .a = 1, .b = 2, .c = 4 }; const b_field = readVarPackedInt(u64, std.mem.asBytes(&st), @bitOffsetOf(T, “b”), 7, builtin.cpu.arch.endian(), .unsigned);

Parameters

T: type,
bytes: []const u8,
bit_offset: usize,
bit_count: usize,
endian: std.builtin.Endian,
signedness: std.builtin.Signedness,