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.
§Shape of the container
A fixed 64-byte header, a BIF file table and a key table each located by their own header offset, and a region of BIF filenames that is not a located block at all: every file entry carries its own offset and length into it, so the strings are addressed one at a time.
§Resolving a resource
The resource_id on a key entry is two numbers packed into one word, and
unpacking it is the whole job of this format:
- bits
31..20index the BIF file table - bits
19..0index the resource within that BIF
So a lookup is: match the resref and type in the key table, split the
resource_id, pick the BIF with the high bits and the entry inside it with
the low bits. That split is also where the format’s ceilings come from,
4,096 BIFs and about a million resources in each.
Byte-level field maps for the header, the file entry and the key entry live
in docs/src/formats/archives/key.md, with the engine’s own load sequence.
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.