Expand description
Port-only: a compact binary encoding for the values that cross between
wasm instances (mln_renderer’s tile/worker_codec).
A Wire type writes itself to a byte vector and reads itself from a
Reader over a slice. Both are concrete, so each type compiles to one
write function and one read function, without the visitors and error
plumbing a serde format compiles for each type. The encoding is
postcard’s: unsigned integers as LEB128 varints, signed ones zigzagged
first, floats as their little-endian bytes, a sequence as its length and
its items, an Option as a byte 0 or 1, a struct as its fields in order
and an enum as its variant index and then its fields.
#[derive(Wire)] writes the impl for a struct or an enum
(mln_wire_derive).
A value that needs more than its bytes to cross, such as the registry
that a name resolves against, gets it from the Context that the
writer or reader was made with.
Structs§
- Error
- Why a value couldn’t be read.
- Reader
- Reads values from the start of a slice, in a context, and keeps why one couldn’t be.
- Request
- A request for the part of a
Contextof one type. - Writer
- Where values are written: bytes, the first value that couldn’t be, and the context they are written in.
Traits§
- Context
- What values need beyond their bytes to cross: the tables of the values
that crossed before, the registry that names resolve against. A value
asks its writer or reader for the part it needs by the part’s type
(
Writer::context,Reader::context). - Wire
- A value that crosses between wasm instances.
Functions§
- from_
slice - The value that fills
bytes. - from_
slice_ in - The value that fills
bytes, read incontext. - read_
into - Reads a
Tintoslot, dropping what it held. Not inlined, so that a struct of many fields (#[wire(default)]) calls it once per field rather than holding each field’s read, move and drop. - read_
seq - Reads a sequence’s length and its items.
- read_
str - Reads a string, borrowed from the input.
- to_vec
valueencoded, or why it can’t be.- to_
vec_ in valueencoded incontext, or why it can’t be.- write_
seq - Writes a sequence’s length and its items.
- write_
str - Writes a string.
- write_
tag - Writes an enum’s variant index.
- write_
varint - Writes a varint.