pub trait Node: Send + Sync {
// Required method
fn run<'life0, 'async_trait>(
&'life0 self,
ctx: NodeContext,
) -> Pin<Box<dyn Future<Output = Result<NodeOutput>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn name(&self) -> &str { ... }
fn effect(&self) -> Effect { ... }
}Expand description
The node trait: an async unit of computation over shared state.
Implement this directly for stateful nodes, or just pass an async closure
to crate::graph::GraphBuilder::add_node — a blanket impl covers any
Fn(NodeContext) -> impl Future<Output = Result<NodeOutput>> + Send + Sync.
Contract (enforced by the executor, documented here):
- Nodes read state only from
NodeContext::state(the super-step snapshot) and express all state changes viaNodeOutput::updates. - Node logic must be idempotent: on interrupt-resume or partial-failure recovery the node re-executes from its start.
Required Methods§
Sourcefn run<'life0, 'async_trait>(
&'life0 self,
ctx: NodeContext,
) -> Pin<Box<dyn Future<Output = Result<NodeOutput>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn run<'life0, 'async_trait>(
&'life0 self,
ctx: NodeContext,
) -> Pin<Box<dyn Future<Output = Result<NodeOutput>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute the node against a super-step state snapshot.
Provided Methods§
Sourcefn name(&self) -> &str
fn name(&self) -> &str
Human/log-friendly name. Closure nodes default to "anonymous";
the graph tracks nodes by the name given to add_node, which is the
authoritative identity.
Sourcefn effect(&self) -> Effect
fn effect(&self) -> Effect
The declared default effect classification of this node (Flight Recorder, R0.5): recorded on the node’s journal events and used by retry/replay policy.
The default is crate::record::Effect::Pure — a plain compute node
over its state snapshot. Override honestly: a node that performs
I/O or side effects inside run is not Pure, and misdeclaring it
weakens replay fidelity (the journal will claim an effect was
re-derivable when it was not). crate::remote::RemoteNode and the
wasm-feature WasmNode override to NonIdempotent.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl Node for Arc<dyn Node>
Allow Arc<dyn Node> itself to be registered as a node (useful for
sharing one node implementation across graphs).
impl Node for Arc<dyn Node>
Allow Arc<dyn Node> itself to be registered as a node (useful for
sharing one node implementation across graphs).