Expand description
Tilewright content packs (docs/spec/PACK.md): one SQLite file compiled
deterministically from a validated world, named by its SHA-256 digest.
let world = tilewright_source::load(Path::new("content")).expect("valid source");
let written = tilewright_pack::write_pack(&world, Path::new("dist"))?;
let pack = tilewright_pack::Pack::open(&written.path)?;
let summary = pack.verify()?;
println!("{} chunks", summary.chunks);Structs§
- Anchor
- A named position on a plane.
- Chunk
Data - A decoded chunk. Strings are IDs into the pack’s
stringstable. - Decode
Error - Why a chunk record was rejected.
- Definition
- A definition row and its stored document.
- Object
Record - Pack
- Page
- Which rows of a listing to visit: those after the row whose key is
after, in the listing’s key order, at mostlimitof them, and no more once their text reachesbytes. A listing reads a page with one query that starts atafterin the table’s primary key, so a caller can walk a table a page at a time, holding one page, and resume from the last key it saw. - Plane
- A plane row and its stored document.
- Stairwell
Tile - The stairwell step on a tile.
- Summary
- Row counts of a pack.
- UidLocation
- Where the object with a uid is: its chunk, and its index in the chunk
record’s depth-first order (see
ChunkData::object). - Verify
Limits - Bounds on the work opening and verifying a pack may do.
- Written
- A pack written to disk.
- Zone
- A zone row and its stored entry.
Enums§
- Error
- Error
Code - Stable codes for why a pack failed to open, read or verify, one per rule
of
docs/spec/PACK.mdsection 3. The Go reader reports the same codes, and the conformance fixtures infixtures/packspin them. - Field
Record - Identity
- One identity of a pack, as
Pack::visit_identitieslists it. Documents are the stored canonical JSON: a plane’s or definition’s document, or a zone’s or stairwell’s entry. - Portal
Record
Constants§
- APPLICATION_
ID - SQLite
application_idof a pack:"TWP1". - CHUNK_
ENCODING - The
chunks.encodingvalue of this encoding. - COMPILER
- The
compilermeta value. - DEFAULT_
MAXIMUM_ DECODED_ BYTES - The default
VerifyLimits::maximum_decoded_bytes: 8 GiB. - DEFAULT_
MAXIMUM_ PACK_ BYTES - The default
VerifyLimits::maximum_pack_bytes: 8 GiB. - FORMAT
- The
meta.formatvalue. - MAXIMUM_
CHUNK_ BYTES - Largest stored (compressed) chunk accepted: zstd’s compression bound for
a record of
MAXIMUM_RECORD_BYTES, so every encoded chunk fits. - MAXIMUM_
DEPTH - Deepest inventory nesting accepted.
- MAXIMUM_
OBJECT_ INDEX - The largest
objectindex anobject_uidsrow may hold. Every object takes more than one byte of a record of at most 16 MiB, so every index is below this. - MAXIMUM_
RECORD_ BYTES - Largest decompressed record accepted.
- META_
KEYS - Every
metakey, in byte order. A pack has exactly these. - RECORD_
VERSION - The
versionof atwc1record of this format. - SCHEMA_
TABLES - The pack tables, by name, exactly as created.
- USER_
VERSION - SQLite
user_versionof a pack of this format. - ZSTD_
LEVEL - zstd compression level used by the compiler.
Functions§
- compile
- Compiles a world into pack bytes. The same world and compiler version always produce the same bytes.
- decode_
chunk - Decompresses and decodes a chunk into its full model. Objects take more memory decoded than encoded, so the model of a 16 MiB record can be several times its size; verification checks objects as they decode instead of building it.
- decode_
record - Decodes an uncompressed
twc1record. - encode_
chunk - Encodes and compresses a chunk.
- encode_
record - Encodes a chunk as an uncompressed
twc1record. - write_
pack - Compiles a world and writes it to
directory/<sha256>.twpack, creating the directory if needed. The write is atomic and never replaces a different file.