Expand description
Shared binary utilities and lightweight format codec traits. Shared binary helpers and lightweight codec traits.
This module is the low-level utility layer used across format modules for:
- checked primitive reads (
u16,u32,u64,f32, fourcc), - bounds validation for offset/size pairs,
- narrow encode/decode traits used for composition.
§Layering Overview
format module (erf/rim/gff/tlk/twoda)
-> format-specific error mapping
-> binary::{read_*, write_*, check_*}
-> raw byte slice / writerEnums§
- Binary
Layout Error - Shared binary layout/read error used by low-level format helpers.
Traits§
- Decode
Binary - Minimal decode trait for binary format value types.
- Encode
Binary - Minimal encode trait for binary format value types.
Functions§
- check_
range_ in_ bounds - Validates that
[offset, offset + size)is withintotal_len. - check_
slice_ in_ bounds - Validates that
[offset, offset + size)is withinbytes. - checked_
to_ usize - Converts a 32-bit offset/count value to
usizewith overflow checking. - expect_
any_ fourcc - Validates that a parsed fourcc matches one of
expected. - expect_
fourcc - Validates that a parsed fourcc exactly matches
expected. - matches_
resource_ key - Returns
truewhen two resource keys match by type and ASCII case-insensitive resource name. - read_
c_ string - Reads a variable-length null-terminated string from a byte buffer.
- read_
f32 - Reads little-endian
f32atoffset. - read_
fixed_ c_ string - Reads a null-terminated string from a fixed-size field in a byte buffer.
- read_
fourcc - Reads a 4-byte tag at
offset. - read_
i32 - Reads little-endian
i32atoffset. - read_u8
- Reads a single byte at
offset. - read_
u16 - Reads little-endian
u16atoffset. - read_
u32 - Reads little-endian
u32atoffset. - read_
u64 - Reads little-endian
u64atoffset. - write_
cp1252 - Encodes
textas Windows-1252 and writes it towriter. - write_
f32 - Writes little-endian
f32. - write_
fixed_ c_ string - Writes a null-terminated string into a fixed-size field, zero-padded.
- write_
fourcc - Writes a 4-byte tag.
- write_
i32 - Writes little-endian
i32. - write_
u8 - Writes a single byte.
- write_
u16 - Writes little-endian
u16. - write_
u32 - Writes little-endian
u32. - write_
u64 - Writes little-endian
u64.