Skip to main content

Crate tilewright_pack

Crate tilewright_pack 

Source
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.
ChunkData
A decoded chunk. Strings are IDs into the pack’s strings table.
DecodeError
Why a chunk record was rejected.
Definition
A definition row and its stored document.
ObjectRecord
Pack
Page
Which rows of a listing to visit: those after the row whose key is after, in the listing’s key order, at most limit of them, and no more once their text reaches bytes. A listing reads a page with one query that starts at after in 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.
StairwellTile
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).
VerifyLimits
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
ErrorCode
Stable codes for why a pack failed to open, read or verify, one per rule of docs/spec/PACK.md section 3. The Go reader reports the same codes, and the conformance fixtures in fixtures/packs pin them.
FieldRecord
Identity
One identity of a pack, as Pack::visit_identities lists it. Documents are the stored canonical JSON: a plane’s or definition’s document, or a zone’s or stairwell’s entry.
PortalRecord

Constants§

APPLICATION_ID
SQLite application_id of a pack: "TWP1".
CHUNK_ENCODING
The chunks.encoding value of this encoding.
COMPILER
The compiler meta 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.format value.
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 object index an object_uids row 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 meta key, in byte order. A pack has exactly these.
RECORD_VERSION
The version of a twc1 record of this format.
SCHEMA_TABLES
The pack tables, by name, exactly as created.
USER_VERSION
SQLite user_version of 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 twc1 record.
encode_chunk
Encodes and compresses a chunk.
encode_record
Encodes a chunk as an uncompressed twc1 record.
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.