fn writePackedInt(comptime T: type, bytes: []u8, bit_offset: usize, value: T, endian: Endian) void

Stores an integer to packed memory. Asserts that buffer contains at least bit_offset + @bitSizeOf(T) bits.

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

Parameters

T: type,
bytes: []u8,
bit_offset: usize,
value: T,
endian: Endian,