Skip to main content

Crate mlua_flow_ir

Crate mlua_flow_ir 

Source
Expand description

flow.ir async runtime + mlua binding.

Layer 3 of the 4-layer flow.ir stack:

  1. flow-ir-lua — Pure Lua DSL (separate repo, ecosystem-neutral)
  2. flow-ir-core — Pure Rust schema + sync interpreter (no mlua, no async)
  3. mlua-flow-irthis crate: re-export of flow-ir-core + AsyncDispatcher + eval_async + fanout_eval + Lua module() binding
  4. mlua-swarm-engine — host concerns (Spawner / Worker / Loop / AuthzPolicy / cp_state persist)

All schema types (Node / Expr / JoinMode / EvalError / Dispatcher) are re-exported verbatim from flow-ir-core so callers can keep a single import path:

use mlua_flow_ir::{eval, eval_async, AsyncDispatcher, Dispatcher, EvalError, Expr, Node};

Structs§

ExternMap
HashMap-backed Externs impl for host-side Rust closures.
MemoryCtx
Default CtxStorage impl — Arc<Mutex<Value>> wrapper。
NoExterns
Empty registry — every call_extern raises ExternError (parity with canonical “requires opts.externs” error). Used by the externs-less compat wrappers (eval / eval_expr / eval_with_storage).

Enums§

EvalError
Evaluation error.
Expr
flow.ir Expr op.
JoinMode
Fanout join semantics (Promise / futures combinators).
Node
flow.ir Node kind.

Traits§

AsyncDispatcher
Async dispatcher trait — async 版 Dispatcher
CtxStorage
Ctx backend trait — eval(_with_storage) 系が ctx state を touch する 唯一の経路。 &self write (interior mutability) で 走行中の Flow と 外部 task が同じ ctx を共有 できる (= dispatch().await suspend 中に外部 task が ctx.write で State 注入 → resume 後 Step が read で観測、 という dynamic injection 経路を成立させる)。
Dispatcher
Dispatcher callback: resolves a Step.ref against the provided input, returns the step’s raw output value.
Externs
Extern registry: resolves a call_extern.ref against evaluated args and returns the value. Mirror of canonical opts.externs (flow-ir-lua interpreter.lua): each entry MUST be a pure function — no side effects, no flow control, value-shape manipulation only.

Functions§

eval
Legacy Value-passing sync evaluator — backward compat wrapper around eval_with_storage + MemoryCtx. Value を所有権で受け取り、 内部で MemoryCtx::new(ctx) を使って storage 版に委譲、 終了後の snapshot を返す。
eval_async
Legacy Value-passing async evaluator — backward compat wrapper around eval_async_with_storage + MemoryCtx. 既存 caller (= dynamic injection を要求しない用途) は引き続きこの API で OK。
eval_async_externs
eval_async + externs registry for call_extern Expr resolution.
eval_async_with_storage
Evaluate a Node against a context value asynchronously, using the given async dispatcher for Step resolution.
eval_async_with_storage_externs
eval_async_with_storage + externs registry for call_extern Expr resolution. externs must be Sync so the recursive future stays Send (host executors spawn it across threads).
eval_expr
Evaluate an Expr against a context value, returning the resolved JSON value. Externs-less compat wrapper — call_extern raises ExternError.
eval_expr_with_externs
eval_expr + externs registry for call_extern Expr resolution.
eval_externs
eval + externs registry for call_extern Expr resolution.
eval_with_storage
Storage-backed sync evaluator — CtxStorage 経由で ctx を touch する正本。
eval_with_storage_externs
eval_with_storage + externs registry for call_extern Expr resolution.
is_truthy
JSON value の truthy 判定 (= flow.ir Branch cond / Loop cond で使う)。 Bool は値そのまま、 null/false 以外は truthy (Lua / JS と整合)。
module
Register the flow module table with Lua.
read_path
Read a path from a JSON value. Supports simple $.a.b.c form.
write_path
Write a value at the path location inside ctx, returning the updated ctx. out must be a Path Expr.

Type Aliases§

ExternFn
Boxed pure extern function stored in ExternMap.