pack

Binary Pack/Unpack

Functions

FunctionDescription
pack_i8Write 1 byte. Returns off+1.
pack_i16_leWrite 2 bytes little-endian. Returns off+2.
pack_i16_beWrite 2 bytes big-endian. Returns off+2.
pack_i32_leWrite 4 bytes little-endian. Returns off+4.
pack_i32_beWrite 4 bytes big-endian. Returns off+4.
pack_i64_leWrite 8 bytes little-endian. Returns off+8.
pack_i64_beWrite 8 bytes big-endian. Returns off+8.
pack_strWrite length-prefixed string (4-byte LE length + raw bytes). Returns new offset.
pack_rawWrite raw bytes (no length prefix). Returns new offset.
unpack_i8Read 1 unsigned byte.
unpack_i16_leRead 2 bytes little-endian.
unpack_i16_beRead 2 bytes big-endian.
unpack_i32_leRead 4 bytes little-endian.
unpack_i32_beRead 4 bytes big-endian.
unpack_i64_leRead 8 bytes little-endian.
unpack_i64_beRead 8 bytes big-endian.
unpack_strRead length-prefixed string. Reads 4-byte LE length, then copies bytes to out…
unpack_str_lenGet string length from length-prefixed string at offset.

Details

pack_i8

fn pack_i8(buf: &i8, off: i64, val: i64) -> i64

Write 1 byte. Returns off+1.

pack_i16_le

fn pack_i16_le(buf: &i8, off: i64, val: i64) -> i64

Write 2 bytes little-endian. Returns off+2.

pack_i16_be

fn pack_i16_be(buf: &i8, off: i64, val: i64) -> i64

Write 2 bytes big-endian. Returns off+2.

pack_i32_le

fn pack_i32_le(buf: &i8, off: i64, val: i64) -> i64

Write 4 bytes little-endian. Returns off+4.

pack_i32_be

fn pack_i32_be(buf: &i8, off: i64, val: i64) -> i64

Write 4 bytes big-endian. Returns off+4.

pack_i64_le

fn pack_i64_le(buf: &i8, off: i64, val: i64) -> i64

Write 8 bytes little-endian. Returns off+8.

pack_i64_be

fn pack_i64_be(buf: &i8, off: i64, val: i64) -> i64

Write 8 bytes big-endian. Returns off+8.

pack_str

fn pack_str(buf: &i8, off: i64, src: &i8, len: i64) -> i64

Write length-prefixed string (4-byte LE length + raw bytes). Returns new offset.

pack_raw

fn pack_raw(buf: &i8, off: i64, src: &i8, len: i64) -> i64

Write raw bytes (no length prefix). Returns new offset.

unpack_i8

fn unpack_i8(buf: &i8, off: i64) -> i64

Read 1 unsigned byte.

unpack_i16_le

fn unpack_i16_le(buf: &i8, off: i64) -> i64

Read 2 bytes little-endian.

unpack_i16_be

fn unpack_i16_be(buf: &i8, off: i64) -> i64

Read 2 bytes big-endian.

unpack_i32_le

fn unpack_i32_le(buf: &i8, off: i64) -> i64

Read 4 bytes little-endian.

unpack_i32_be

fn unpack_i32_be(buf: &i8, off: i64) -> i64

Read 4 bytes big-endian.

unpack_i64_le

fn unpack_i64_le(buf: &i8, off: i64) -> i64

Read 8 bytes little-endian.

unpack_i64_be

fn unpack_i64_be(buf: &i8, off: i64) -> i64

Read 8 bytes big-endian.

unpack_str

fn unpack_str(buf: &i8, off: i64, out: &i8) -> i64

Read length-prefixed string. Reads 4-byte LE length, then copies bytes to out. Returns new offset (past string data).

unpack_str_len

fn unpack_str_len(buf: &i8, off: i64) -> i64

Get string length from length-prefixed string at offset.