Skip to main content

Module wire

Module wire 

Source
Expand description

Shared wire-codec core — the exact byte format of the peer/transport codec (logicaffeine_compile::concurrency::marshal), factored out so that TWO value models encode and decode through ONE definition:

  • the interpreter’s RuntimeValue (host side), and
  • AOT-generated Rust enum/struct types (native side).

Because both go through this module, the wire bytes are byte-identical by construction — not a parallel re-implementation that can drift. This is what lets a compile-once native partial evaluator receive a program as data over the real fast codec, at native speed.

The tag bytes and field layout MUST stay in lockstep with marshal.rs; the wire_bytes_match_peer_codec test in logicaffeine_compile proves it.

Constants§

T_FALSE
Boolean false.
T_FLOAT
An IEEE-754 double, 8 little-endian bytes.
T_INDUCTIVE
An inductive/enum value: type_name string, constructor string, varint arg count, args.
T_INT
A signed integer, zig-zag + LEB128 varint.
T_LIST
A heterogeneous list: varint element count, then each element (tagged).
T_NOTHING
Nothing / unit.
T_TEXT
A UTF-8 string: varint byte-length, then the bytes.
T_TRUE
Boolean true.

Traits§

WireDecode
A value that reconstructs from the shared wire format.
WireEncode
A value that serializes into the shared wire format.

Functions§

expect_tag
Read the tag byte at pos and advance; None if it is not expected.
read_inductive_header
Read an inductive header, returning (type_name, constructor, nargs). The caller dispatches on constructor and reads nargs arguments via WireDecode.
read_str
Inverse of write_str; None on truncation or invalid UTF-8.
read_uvarint
Inverse of write_uvarint; None on truncation or overlong (>64-bit) input.
unzigzag
Inverse of zigzag.
write_inductive_header
Write the header of an inductive value: T_INDUCTIVE, its type_name, its constructor, and the argument count. The args themselves follow, each written via WireEncode.
write_str
A length-prefixed UTF-8 string, UNtagged (used for inductive type_name/constructor).
write_uvarint
LEB128 unsigned varint.
zigzag
Map a signed integer onto an unsigned one so small magnitudes stay short.