Skip to main content

text_read_construct_expr

Function text_read_construct_expr 

Source
pub fn text_read_construct_expr(class: Symbol, form: impl Into<String>) -> Expr
Expand description

Builds the citizen/read-construct Expr for a v1 text citizen form.

Text-form citizens (pitch, chord, MIDI, and sound shapes) read-construct from a single canonical string tagged with the v1 form version. This is the shared spelling of that wire form: a citizen/read-construct extension whose payload is the vector [class, v1, form].

The kernel owns Expr and Symbol; this helper only assembles them, so it adds no dependency beyond the kernel.

ยงExamples

let class = Symbol::qualified("pitch", "Pitch");
let expr = text_read_construct_expr(class.clone(), "C4");
assert_eq!(
    expr,
    Expr::Extension {
        tag: Symbol::qualified("citizen", "read-construct"),
        payload: Box::new(Expr::Vector(vec![
            Expr::Symbol(class),
            Expr::Symbol(Symbol::new("v1")),
            Expr::String("C4".to_owned()),
        ])),
    }
);