Expand description
The binary form — what the build compiles content to, what the bus carries, and what the runtime and the Java hosts read, like NBT:
"YOGD" version:u8
root valueA value is a tag byte and its payload. A string is written where it’s
first used and referred to after that: a varint v, then — when v is
odd — v >> 1 bytes of UTF-8, the next entry of the string table; when
it’s even, the table’s entry v >> 1. Repeated keys and ids cost one
varint each, and the writer never goes back over what it wrote.
| Tag | Value | Payload |
|---|---|---|
| 0 | null | — |
| 1, 2 | false, true | — |
| 3 | int | zigzag varint |
| 4 | float | f64, little-endian |
| 5 | string | string |
| 6 | list | varint count, values |
| 7 | map | varint count, (key string, value) pairs |
| 8 | ref | kind string, id string |
| 9 | tag | kind string, id string |
| 10 | resource | set string, key string |
| 11 | text | string |
| 12 | image | string |
| 13 | color | u32, little-endian (0xAARRGGBB) |
| 14 | translation key | string |
| 15 | bytes | varint length, the bytes |
| 16 | list of ints, packed | varint count, zigzag varints |
| 17 | stream | u32 byte length, then varint count and values with their own strings |
| 18 | float, 32-bit | f32, little-endian |
| 19 | list of floats, packed | varint count, f64 each, little-endian |
| 20 | list of 32-bit floats, packed | varint count, f32 each, little-endian |
Nothing is aligned: numbers are read out of the bytes wherever they are, so no padding is ever written.
Varints are LEB128. Decoding checks every length against the input, so malformed bytes are an error, never a panic or a huge allocation.
A crate::Schema writes itself here straight (crate::Schema::encode)
and reads itself back the same way (crate::Schema::decode) — no value
tree on the way.
Modules§
- tag
- A value’s first byte: what it is.
Structs§
- Decode
Error - Malformed binary data.
- Decoder
- Reads the binary form. The step-by-step reads (
Decoder::int,Decoder::map…) answerNonefor anything but whatcrate::Schema::encodewrites there — the schema then reads the slow way, which says what’s wrong. - Writer
- Writes the binary form piece by piece, from data that isn’t a
Value— nothing is built or copied on the way. A map or list is given its length, then that many entries (keythen a value) or values.
Constants§
Functions§
- decode
- Reads the binary form.
- decode_
ref - Reads the binary form borrowed: every string points into
bytes, lists and maps go inarena— nothing is copied. - encode
valuein the binary form.