pack
Binary Pack/Unpack
Functions
| Function | Description |
|---|---|
pack_i8 | Write 1 byte. Returns off+1. |
pack_i16_le | Write 2 bytes little-endian. Returns off+2. |
pack_i16_be | Write 2 bytes big-endian. Returns off+2. |
pack_i32_le | Write 4 bytes little-endian. Returns off+4. |
pack_i32_be | Write 4 bytes big-endian. Returns off+4. |
pack_i64_le | Write 8 bytes little-endian. Returns off+8. |
pack_i64_be | Write 8 bytes big-endian. Returns off+8. |
pack_str | Write length-prefixed string (4-byte LE length + raw bytes). Returns new offset. |
pack_raw | Write raw bytes (no length prefix). Returns new offset. |
unpack_i8 | Read 1 unsigned byte. |
unpack_i16_le | Read 2 bytes little-endian. |
unpack_i16_be | Read 2 bytes big-endian. |
unpack_i32_le | Read 4 bytes little-endian. |
unpack_i32_be | Read 4 bytes big-endian. |
unpack_i64_le | Read 8 bytes little-endian. |
unpack_i64_be | Read 8 bytes big-endian. |
unpack_str | Read length-prefixed string. Reads 4-byte LE length, then copies bytes to out… |
unpack_str_len | Get string length from length-prefixed string at offset. |
Details
pack_i8
fn pack_i8(buf: &i8, off: i64, val: i64) -> i64Write 1 byte. Returns off+1.
pack_i16_le
fn pack_i16_le(buf: &i8, off: i64, val: i64) -> i64Write 2 bytes little-endian. Returns off+2.
pack_i16_be
fn pack_i16_be(buf: &i8, off: i64, val: i64) -> i64Write 2 bytes big-endian. Returns off+2.
pack_i32_le
fn pack_i32_le(buf: &i8, off: i64, val: i64) -> i64Write 4 bytes little-endian. Returns off+4.
pack_i32_be
fn pack_i32_be(buf: &i8, off: i64, val: i64) -> i64Write 4 bytes big-endian. Returns off+4.
pack_i64_le
fn pack_i64_le(buf: &i8, off: i64, val: i64) -> i64Write 8 bytes little-endian. Returns off+8.
pack_i64_be
fn pack_i64_be(buf: &i8, off: i64, val: i64) -> i64Write 8 bytes big-endian. Returns off+8.
pack_str
fn pack_str(buf: &i8, off: i64, src: &i8, len: i64) -> i64Write 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) -> i64Write raw bytes (no length prefix). Returns new offset.
unpack_i8
fn unpack_i8(buf: &i8, off: i64) -> i64Read 1 unsigned byte.
unpack_i16_le
fn unpack_i16_le(buf: &i8, off: i64) -> i64Read 2 bytes little-endian.
unpack_i16_be
fn unpack_i16_be(buf: &i8, off: i64) -> i64Read 2 bytes big-endian.
unpack_i32_le
fn unpack_i32_le(buf: &i8, off: i64) -> i64Read 4 bytes little-endian.
unpack_i32_be
fn unpack_i32_be(buf: &i8, off: i64) -> i64Read 4 bytes big-endian.
unpack_i64_le
fn unpack_i64_le(buf: &i8, off: i64) -> i64Read 8 bytes little-endian.
unpack_i64_be
fn unpack_i64_be(buf: &i8, off: i64) -> i64Read 8 bytes big-endian.
unpack_str
fn unpack_str(buf: &i8, off: i64, out: &i8) -> i64Read 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) -> i64Get string length from length-prefixed string at offset.