Skip to main content

Module binary

Module binary 

Source
Expand description

The binary form — what the build compiles content to and the runtime and the Java hosts read, like NBT:

"YOGD" version:u8
strings: varint count, then each as varint length + UTF-8
root value

A value is a tag byte and its payload; every string (map keys too) is an index into the table, so repeated keys and ids cost one varint each.

TagValuePayload
0null—
1, 2false, true—
3intzigzag varint
4floatf64, little-endian
5stringstring
6listvarint count, values
7mapvarint count, (key string, value) pairs
8refkind string, id string
9tagkind string, id string
10resourceset string, key string
11textstring
12imagestring
13coloru32, little-endian (0xAARRGGBB)
14translation keystring

Varints are LEB128. Decoding checks every length against the input, so malformed bytes are an error, never a panic or a huge allocation.

Structs§

DecodeError
Malformed binary data.
Writer
Writes the binary form piece by piece, from data that isn’t a Value — nothing is built or copied on the way; strings are borrowed until Writer::finish. A map or list is given its length, then that many entries (key then a value) or values.

Constants§

MAGIC
MAX_DEPTH
Nested deeper than this is malformed.
VERSION

Functions§

decode
Reads the binary form.
decode_ref
Reads the binary form borrowed: every string points into bytes, lists and maps go in arena — nothing is copied. What a schema reads fastest (crate::read_bytes).
encode
value in the binary form.