Skip to main content

Module encode

Module encode 

Source
Expand description

Network encoding of paletted container entries.

Entries are packed like vanilla SimpleBitStorage: 64 / bits entries per long, low bits first, no entry spanning two longs, longs written big-endian.

StructsΒ§

PaletteIndexTable πŸ”’
The thread’s index table filled with one palette, reset to empty when dropped (including on unwind) so the next palette starts from a clean table.

ConstantsΒ§

EMPTY_SLOT πŸ”’
Marks an index-table slot whose global id is not in the palette being encoded.
INDEX_TABLE_LEN πŸ”’
Global ids are u16-backed, so a table indexed by global id has this many slots.
MAX_PACKED_BYTES πŸ”’
Largest packed payload: a 16Γ—16Γ—16 section at 16 bits per entry.
PALETTE_INDEX πŸ”’
Palette index per global id, reused across encodes on this thread. It takes 128 KiB on each thread that encodes a section, allocated on first use.

FunctionsΒ§

invalid_data πŸ”’
pack πŸ”’
Packs values into buffer, failing if a value has no entry.
pack_global_ids πŸ”’
Packs each value’s global id into buffer and returns the packed bytes.
pack_longs πŸ”’
Packs values into the front of buffer, failing if a value has no entry.
pack_palette_indices πŸ”’
Packs each value’s index in palette into buffer and returns the packed bytes.