Expand description
KEY index support. KEY binary reader and writer.
KEY files are global resource indexes that map (resref, type) pairs to a
packed resource_id that identifies both:
- which BIF file contains the resource, and
- which entry inside that BIF file to load.
§Format Layout
+------------------------------+ 0x0000
| Header (64 bytes) |
+------------------------------+ file_table_offset
| BIF file table |
| 12 bytes * bif_count |
+------------------------------+ filename table (from file entries)
| BIF filenames |
| variable-size strings |
+------------------------------+ key_table_offset
| Resource key table |
| 22 bytes * key_count |
+------------------------------+§BIF File Entry (12 bytes)
0x00..0x04 file_size (u32)
0x04..0x08 filename_offset (u32)
0x08..0x0A filename_size (u16)
0x0A..0x0C drives (u16)§Key Entry (22 bytes)
0x00..0x10 resref[16] (null padded)
0x10..0x12 type_id (u16)
0x12..0x16 resource_id (u32)§Header (64 bytes)
0x00..0x04 magic ("KEY ")
0x04..0x08 version ("V1 " or "V1.1")
0x08..0x0C bif_count (u32)
0x0C..0x10 key_count (u32)
0x10..0x14 file_table_offset (u32)
0x14..0x18 key_table_offset (u32)
0x18..0x1C build_year (u32, years since 1900)
0x1C..0x20 build_day (u32, day of year)
0x20..0x40 reserved (32 bytes, preserved verbatim)resource_id bit layout:
- bits 31..20: BIF index
- bits 19..0: resource index within that BIF
Structs§
- Key
- In-memory KEY container.
- KeyBif
Entry - One BIF file-table entry in a KEY index.
- KeyRead
Options - KEY reader option set.
- KeyResource
Entry - One resource entry in the KEY key table.
Enums§
- KeyBinary
Error - Errors produced while parsing or serializing KEY binary data.
- KeyRead
Mode - KEY reader input policy.
Functions§
- pack_
resource_ id - Packs
(bif_index, resource_index)into KEYresource_idformat. - read_
key - Reads a KEY index from a reader.
- read_
key_ from_ bytes - Reads a KEY index from bytes.
- read_
key_ from_ bytes_ with_ options - Reads a KEY index from bytes with explicit options.
- read_
key_ with_ options - Reads a KEY index from a reader with explicit options.
- write_
key - Writes a KEY index to a writer.
- write_
key_ to_ vec - Serializes a KEY index to bytes.