Skip to main content

enum_to_wit

Function enum_to_wit 

Source
pub fn enum_to_wit(
    item: &ItemEnum,
    known: &BTreeSet<String>,
) -> Result<(Vec<String>, String), String>
Expand description

Render a Rust enum to WIT: a variant <name> { ... } plus any synthetic records for struct-shaped cases. Returns (synthetic_records, variant).

Case shapes: unit → case; single tuple field → case(type); named fields (Case { .. }) → a synthesized record <enum>-<case> and case(<enum>-<case>). A multi-field tuple case is rejected: WIT cases take one payload, and a multi-field tuple serializes as a sequence (not a record) via serde, so it can’t round-trip — use a struct variant Case { .. } instead.