Expand description
Encoding strategies — the conventions for mapping Rust shapes onto WXF
expressions. These sit a layer above the cursor (WxfReader/WxfWriter,
which only know raw WXF tokens) and are shared by the #[derive] codegen and
the hand-written std impls (Option, Result, …) so the wire format lives
in exactly one place.
§Enum representation
A Rust enum is encoded as a List where the first element is the variant
name (a string) and the remaining elements are the payload:
None {"None"}
Some(v) {"Some", v}
Rect(w, h) {"Rect", w, h}Constants§
- DEFAULT_
ENUM_ HEAD - Default head for enum variants on the wire:
{"VariantName", data...}.
Functions§
- begin_
data_ variant - Begin a data-carrying variant:
head["VariantName", data...]. The caller writes then_datapayload values immediately after. - read_
data_ header - No-op: the old strategy needed a separate
"Data"key + List header; the new format inlines data directly after the variant name, so there is nothing extra to read. Kept for API compatibility with derived code. - read_
enum_ header - Read an enum list header (token already consumed): skips the head, reads the
variant name string, and returns
(total_arity, variant_name). The caller reads the remainingtotal_arity - 1payload values. - write_
unit_ variant - Write a unit variant:
head["VariantName"]. UseDEFAULT_ENUM_HEADfor the standard{"VariantName"}form.