pub fn statement_from_content(
catalog: &Catalog,
node: &Value,
) -> Result<Statement, StatementContentError>Expand description
Convert one rule-content-v1 statement into the public model.
catalog decides which ids exist and how many arguments they take. The
result is not validated as a program: whether the statement fits its
rule (an If without its End, a value of the wrong type) is for
canonical validation of the edited program.
use serde_json::json;
use workshop_rs::catalog::Catalog;
use workshop_rs::rules::statement::{Statement, statement_from_content};
let catalog = Catalog::builtin().unwrap();
let statement = statement_from_content(
&catalog,
&json!({"call": "wait", "args": [0.5, {"enum": "WaitBehavior", "member": "IGNORE_CONDITION"}]}),
)
.unwrap();
assert!(matches!(statement, Statement::Action(_)));