Expand description
Typesafe writer + reader for the host <-> wasm binary handshake.
Spec: docs/internal/adr/wasm-binary-layout-v1-2026-05-16.md.
BufferBuilder writes scalar fields by name into a pre-allocated
byte buffer sized by a crate::layout::OffsetTable; BufferReader
reads the same fields back. The intermediate Vec<u8> is exactly
what the host hands the wasm module (run_main(in_ptr, in_len, out_ptr)) once Phase 2.b flips the wasm signature; in Phase 2.a
the binary path is dormant but the writer/reader infrastructure is
already in place so host code can be wired ahead of the codegen
flip.
Type safety is enforced at runtime by checking the schema’s
declared type for each field against the writer call (e.g.
write_int on a Bool slot is BufferError::TypeMismatch).
Static enforcement via codegen-generated wrappers is a Phase 3
follow-up.
Structs§
- Buffer
Builder - Type-checked writer over a record buffer with an optional tail area.
- Buffer
Reader - Type-checked reader over a record buffer plus optional tail area.
- List
Record Writer - Phase 10-c: in-flight
List<Schema>element writer.
Enums§
- Buffer
Error - Failure modes when writing / reading typed fields against a buffer.
Functions§
- write_
nested_ pointer_ array_ list - Marshal a
List<List<String>>/List<List<Schema>>(F5: a doubly- nested pointer-array list, where each outer element is itself a pointer-array list) intofield_name’s tail area.inner_elementis the innermost element type (String/Schema/ a deeperList<…>), matching themarshal_list_list_indispatch contract;itemsare the outerValue::Listrows (each itself aList<inner_element>). The whole nested structure is written at child-buffer-relative offsets and the field’s pointer slot patched to the outer header — the relocation walker’sPtrArrayElem::InnerListdescriptor rebases the inner pointer arrays on the later arena rebase. - write_
nested_ scalar_ list - Marshal a nested
List<List<scalar>>arg / schema field intofield_name’s tail area, given the inner elementTypeReprand the outerValue::Listitems (each element itself aValue::Listof inline-fixed scalars). Shared by both compiled backends so they emit byte-identical input buffers. Inner pointer-array element lists (List<List<String>>/List<List<Schema>>) are rejected by the layout pass before reaching here; this routine only handles the inline-fixed innermost elements (Int/Float/Bool).