The Reflow Runtime
reflow_rt is the public Rust API for Reflow.
Reflow is a modular workflow execution engine that uses the actor model for concurrent, message-passing computation. It enables graph-authored DAGs for data processing, real-time media, visual tooling, distributed workflows, and optional ML/CV taskpacks.
Use this crate when you are building applications, tools, services, examples, or taskpacks on top of Reflow. It is the stable runtime surface for authoring graph workflows, registering actors, running networks, streaming media, and opting into larger component families such as GPU rendering, native camera capture, API-service actors, and ML/CV pipelines.
The lower-level crates still exist because Reflow is modular internally. Application code should start here.
[]
= "0.1"
= { = "1", = ["macros", "rt-multi-thread"] }
Runtime Model
Reflow runs actor graphs.
| Concept | Runtime Meaning |
|---|---|
| Graph | A DAG of nodes, edges, initial packets, exposed ports, and subgraph boundaries. |
| Actor | A concurrent processing unit with named input and output ports. |
| Message | The packet format moved across graph edges, including bytes, objects, encoded values, and stream handles. |
| Network | The executable runtime that owns actors, routes packets, starts processes, and emits runtime events. |
| Component | A reusable actor template that can be discovered by editors and registered into a network. |
| Taskpack | A reusable graph/subgraph package for higher-level workflows such as media or ML pipelines. |
The same topology can be authored by code, generated by tools, or loaded from graph exports. Reflow does not require hardcoded pipelines in framework code; graph structure remains the source of truth.
Quick Start — Build And Run A Network
Register a template, add a node, wire it up, start.
use *;
use json;
use HashMap;
async
Connector, ConnectionPoint, and InitialPacket come from reflow_rt::network::connector. The prelude re-exports the most common authoring types.
Observing Runtime Events
Subscribe before calling net.start() so no events are missed.
use NetworkEvent;
let events = net.get_event_receiver;
spawn;
Loading A Graph Export
Editors and tools persist flows as GraphExport JSON. Load once, hand to the network.
use ;
use ;
let json = read_to_string?;
let export: GraphExport = from_str?;
let graph = load;
let net = with_graph;
net.lock.start?;
Templates referenced by nodes must already be registered, either individually or through the bundled component catalog.
Writing A Custom Actor
Use the #[actor(...)] macro from the prelude. Declare in-ports, out-ports, and state; the macro generates the actor struct and wiring.
use *;
use Error;
use HashMap;
pub async
// Register with a stable template id.
net.register_actor_arc?;
net.add_node?;
ActorContext exposes the current payload, config, shared state, and StreamHandle access. Returning a HashMap means "emit these packets on these ports"; returning an empty map means "consumed, no output this tick".
Subgraphs
Reuse authored flows as first-class actors. A SubgraphActor embeds a GraphExport and participates in the parent network like any other actor.
use *;
let inner: GraphExport = from_str?;
let subgraph = new;
net.register_actor_arc?;
net.add_node?;
Expose only the ports the parent DAG needs to touch; internal wiring stays private to the subgraph.
Streams And Media
Large or continuous payloads travel as Message::StreamHandle. Consumers take a typed receiver and iterate until the stream ends.
use ;
if let Some = ctx.get_payload.get.cloned
This is how tpl_render_frame_collector → tpl_video_encoder → tpl_file_save moves 4K RGBA frames without copying through the message bus.
First Import
use *;
The prelude is intentionally small: graph, network, actor, message, stream, subgraph, and template types that most runtime users need first.
Public Modules
reflow_rt exposes the runtime as named modules. The exact crate names are re-exported for clarity, and short aliases are provided for application ergonomics.
| Runtime module | Alias | What it is for |
|---|---|---|
reflow_rt::reflow_graph |
graph |
Graph data structures, graph exports, nodes, edges, IIPs, and graph analysis utilities. |
reflow_rt::reflow_actor |
actor_runtime |
Actor traits, actor context, message types, stream handles, ports, and actor state. |
reflow_rt::reflow_network |
network |
Network execution, subgraphs, runtime templates, routing, tracing, and events. |
reflow_rt::reflow_components |
components |
Native actor catalog, component registry, display metadata, and editor templates. |
reflow_rt::reflow_assets |
assets |
Content-addressed asset database conventions. |
reflow_rt::reflow_pixel |
pixel |
Pixel and image utilities for media actors. |
reflow_rt::reflow_sdf |
sdf |
SDF primitives, procedural geometry, and WGSL-oriented codegen support. |
reflow_rt::reflow_shader |
shader |
Shader graph IR and material code generation. |
reflow_rt::reflow_vector |
vector |
2D vector paths, shapes, boolean operations, and rasterization. |
Feature-gated runtime modules include api, dsp, media_types, media_codec, asset_registry, litert, cv_ops, ml_ops, and taskpacks.
Feature Policy
The default runtime is deliberately lean. It gives you the graph runtime and core utility components without pulling in GPU, AV, native camera, API-service generation, browser automation, or native ML runtime dependencies.
# The default: runtime + core utility component catalog.
= "0.1"
# Minimal import surface, if you only want the public modules.
= { = "0.1", = false }
# Opt into exactly the stacks your app needs.
= { = "0.1", = ["gpu", "camera-native", "media", "ml"] }
| Feature | Runtime capability |
|---|---|
components-core |
The lightweight default component surface. |
components-default |
Compatibility bundle matching reflow_components defaults: av-core, gpu, and window-events. |
av-core |
Audio and signal-processing actors through reflow_dsp. |
gpu |
GPU-backed rendering and compute actors. |
window-events |
Window and input event actors. |
browser-events |
Browser event actors, also enabling window-events. |
browser |
Headless browser automation actors. |
video-encode |
Native video encoding support. |
camera-native |
Native camera capture through platform backends. |
media |
Typed frame, tensor, detection, landmark, timestamp, and ROI packets. |
ml |
CV preprocess actors, model manifests, inference actors, decode actors, LiteRT backend boundary, and taskpacks. |
external-litert |
Real LiteRT execution through the optional LiteRT adapter. |
api-services |
Generated API-service actor catalog. |
full |
Broad runtime bundle for applications that want most optional component families. |
network-flowtrace |
Flow tracing support in the network runtime. |
network-wasm |
Wasm-specific network runtime support. |
Real LiteRT execution is always opt-in. The ML stack remains deterministic and mockable unless external-litert is enabled and model manifests request the LiteRT backend.
Editor And Template Runtime
Reflow components carry template metadata for visual editors. The runtime surface exposes:
use ;
use TemplateRegistry;
This keeps authored flows portable: editors can discover templates, users wire DAGs, and the runtime resolves those templates into actors without framework-specific hardcoded pipelines.
Media And ML Runtime
With media and ml, Reflow graphs can author computer vision pipelines while staying graph-driven:
frame -> preprocess -> inference -> decode -> roi/taskpack -> output
A minimal inference graph built from templates:
use *;
use json;
for tpl in
net.add_node?;
net.add_node?;
net.add_node?;
net.add_node?;
Packets remain ordinary Reflow messages. Synchronization uses actor inports. Model behavior comes from manifests and node configuration. Taskpacks are reusable graph exports, not privileged runtime code.
Documentation
- Workspace overview: https://github.com/offbit-ai/reflow#readme
- Reflow docs index: https://github.com/offbit-ai/reflow/tree/main/docs
- Standard component catalog: https://github.com/offbit-ai/reflow/blob/main/docs/components/standard-library.md
- Media / ML stack: https://github.com/offbit-ai/reflow/blob/main/docs/components/ml-stack.md
- Examples: https://github.com/offbit-ai/reflow/tree/main/examples
License
Reflow is dual-licensed under either MIT or Apache-2.0, at your option.