Expand description
flow.ir Pure Rust schema + sync interpreter.
3 Node kinds (Step / Seq / Branch) + Fanout / Loop / Try + 3 Expr ops
(Path / Lit / Eq) + sync eval + Dispatcher trait + Path read/write.
mlua / futures / async 依存ゼロ。 async runtime + mlua binding は上流
mlua-flow-ir crate が担当する 4 層 stack の core 層。
§Quick start
use flow_ir_core::{eval, Dispatcher, EvalError, Expr, Node};
use serde_json::{json, Value};
let node: Node = serde_json::from_value(json!({
"kind": "step",
"ref": "uppercase",
"in": { "op": "path", "at": "$.input" },
"out": { "op": "path", "at": "$.output" },
})).unwrap();
struct Fixture;
impl Dispatcher for Fixture {
fn dispatch(&self, _r: &str, input: Value) -> Result<Value, EvalError> {
if let Value::String(s) = input {
Ok(Value::String(s.to_uppercase()))
} else {
Ok(input)
}
}
}
let out = eval(&node, json!({ "input": "hello" }), &Fixture).unwrap();
assert_eq!(out, json!({ "input": "hello", "output": "HELLO" }));Enums§
- Eval
Error - Evaluation error.
- Expr
- flow.ir Expr op.
- Join
Mode - Fanout join semantics (Promise / futures combinators).
- Node
- flow.ir Node kind.
Traits§
- Dispatcher
- Dispatcher callback: resolves a
Step.refagainst the provided input, returns the step’s raw output value.
Functions§
- eval
- Evaluate a
Nodeagainst a context value, using the given dispatcher forStepresolution. - eval_
expr - Evaluate an
Expragainst a context value, returning the resolved JSON value. - is_
truthy - JSON value の truthy 判定 (= flow.ir Branch cond / Loop cond で使う)。 Bool は値そのまま、 null/false 以外は truthy (Lua / JS と整合)。
- read_
path - Read a path from a JSON value. Supports simple
$.a.b.cform. - write_
path - Write a value at the path location inside ctx, returning the updated ctx.
outmust be aPathExpr.