1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//! Primitive framing helpers shared by the wire encoder and decoder.
/// Canonical wire-header flag bits shared by the encoder and decoder.
pub use ;
/// Wire-format magic bytes and schema version constant.
///
/// `MAGIC` is the four-byte envelope tag `VIR0`; `WIRE_FORMAT_VERSION`
/// is the little-endian `u16` that immediately follows it. Both are
/// written by `Program::to_wire` and validated by `Program::from_wire`
/// before any payload is decoded. A mismatch surfaces an actionable
/// `Fix:` error rather than an opaque downstream parse failure
/// (audit L.1.47).
pub use ;
/// Append a checked sequence length to the wire buffer.
///
/// Converts `usize` → `u32` so the format stays platform-independent.
/// Every variable-length payload (node list, expression tree, string)
/// is prefixed with this length field.
///
/// # Errors
///
/// Returns an actionable error when `value` does not fit in 32 bits.
pub use put_len_u32;
/// Append a bounded length-prefixed UTF-8 string.
///
/// The string length is encoded via [`put_len_u32()`] and the raw bytes
/// follow. Used for buffer names, operation identifiers, and other
/// human-readable tokens carried by the IR.
///
/// # Errors
///
/// Returns an actionable error when the string exceeds
/// `MAX_STRING_LEN` or the length cannot fit in the encoded field.
pub use put_string;
/// Append one little-endian `u32` to the output buffer.
///
/// Used for scalar numeric payloads (tag discriminants, buffer ids,
/// work-group sizes). The wire format is little-endian on all targets.
pub use put_u32;
/// Append one raw byte to the output buffer.
///
/// Used for tag bytes and small enum discriminants where a full
/// `u32` would waste four bytes.
pub use put_u8;
/// Low-level byte-reader methods for the wire decoder.
///
/// These methods advance `Reader::pos`, bounds-check every access,
/// and produce `Fix:`-prefixed errors on truncation or version skew.
/// They are the symmetric counterpart of the `put_*` encoder helpers.
pub
/// Wire-format magic and version constants.
///
/// Defines the `VIR0` magic tag and the current schema version.
/// Audit L.1.47: version mismatch is detected immediately after magic
/// validation so callers receive an actionable error rather than
/// arbitrary downstream parse failures.
/// Length-field encoder for wire-format sequences.
///
/// Bridges Rust `usize` (platform pointer size) to the fixed `u32`
/// length field used in VIR0. Overflow is rejected with a `Fix:` hint
/// so that hostile or oversized programs cannot be serialized.
/// UTF-8 string encoder for the IR wire format.
///
/// Bounds string lengths against `MAX_STRING_LEN` before writing
/// the length-prefixed payload. Guarantees that every encoded string
/// can be decoded without unbounded allocation.
/// Little-endian `u32` framing helper.
///
/// Emits four little-endian bytes for scalar fields. This module
/// contains the canonical implementation; all `u32` wire fields go
/// through here so endianness is consistent across architectures.
/// Single-byte framing helper.
///
/// Emits one raw byte for compact discriminants. Used for enum tags
/// and boolean-like flags where a full multi-byte word is unnecessary.