Expand description
2DA binary table support.
2DA V2.b binary reader and writer.
2DA is a compact table format used for gameplay metadata. The binary form stores column headers, row labels, a cell-offset matrix, and a shared string table.
§Shape of the binary form
Six blocks and no offsets to any of them: signature, column headers, a row count, row labels, a cell offset matrix, and a shared string table. Parsing is strictly sequential, so a malformed block does not cause one bad lookup, it invalidates everything after it.
Cell offsets are u16, which caps the string table at 64 KiB. Deduplication
is what keeps real tables inside that, since a 2DA column is typically a few
distinct values repeated down thousands of rows – which is why this writer
deduplicates rather than merely producing deterministic output. Writing each
cell’s string separately can overflow a table the game ships happily.
Block contents and the text form’s differences are in
docs/src/formats/text/2da.md, with the engine’s own load sequence.
Structs§
- TwoDa
- In-memory representation of a binary 2DA table.
- TwoDa
Binary Options - Encoding options for binary 2DA reader/writer operations.
- TwoDa
Row - One row in a 2DA table.
Enums§
- TwoDa
Binary Error - Errors produced while parsing or serializing binary 2DA data.
Functions§
- read_
twoda - Reads a binary 2DA from a reader.
- read_
twoda_ auto - Auto-detects the format from file extension and reads accordingly.
- read_
twoda_ from_ bytes - Reads a binary 2DA (
2DA V2.b) from in-memory bytes. - read_
twoda_ from_ bytes_ with_ options - Reads a binary 2DA (
2DA V2.b) from in-memory bytes with explicit text options. - read_
twoda_ with_ options - Reads a binary 2DA from a reader with explicit text options.
- write_
twoda - Writes a binary 2DA (
2DA V2.b) to a writer. - write_
twoda_ to_ vec - Serializes a binary 2DA to a byte vector.
- write_
twoda_ to_ vec_ with_ options - Serializes a binary 2DA to a byte vector with explicit text options.
- write_
twoda_ with_ options - Writes a binary 2DA (
2DA V2.b) to a writer with explicit text options.