Module twoda

Module twoda 

Source
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.

§Format Layout

+------------------------------+
| "2DA " + "V2.b" + '\n'       |
+------------------------------+
| Header row text              |
| tab-separated, NUL-terminated|
+------------------------------+
| Row count (u32)              |
+------------------------------+
| Row labels                   |
| each terminated by '\t'      |
+------------------------------+
| Cell offset table            |
| u16 * (rows * columns)       |
+------------------------------+
| String table blob            |
| NUL-terminated cell strings  |
+------------------------------+

Writer output is deterministic: repeated cell strings are deduplicated in the string table while preserving row and column order.

Structs§

TwoDa
In-memory representation of a binary 2DA table.
TwoDaBinaryOptions
Encoding options for binary 2DA reader/writer operations.
TwoDaRow
One row in a 2DA table.

Enums§

TwoDaBinaryError
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.