pub struct Graph<S: GraphState> { /* private fields */ }Expand description
A graph under construction. Generic over the state type S. Convert to
an executable [CompiledGraph] via .compile().
Implementations§
Source§impl<S: GraphState> Graph<S>
impl<S: GraphState> Graph<S>
Sourcepub fn annotate(
self,
node_name: impl Into<String>,
key: impl Into<String>,
value: impl Into<Value>,
) -> Self
pub fn annotate( self, node_name: impl Into<String>, key: impl Into<String>, value: impl Into<Value>, ) -> Self
Attach a key/value annotation to node_name. Annotations are
arbitrary metadata for diagnostics, doc generation, or external
tooling — they don’t affect execution. Multiple annotations per
node are supported; the same key replaces.
No-op (silently) if node_name isn’t registered yet — call
.node(...) before .annotate(...) to keep things tidy.
Sourcepub fn with_version(self, v: impl Into<String>) -> Self
pub fn with_version(self, v: impl Into<String>) -> Self
Stamp a version tag. Echoed in snapshots and (when version_check
is enabled on the runtime) compared against checkpoint version on
resume.
Sourcepub fn node(self, name: impl Into<String>, node: impl Node<S> + 'static) -> Self
pub fn node(self, name: impl Into<String>, node: impl Node<S> + 'static) -> Self
Add a node. The name is the routing key — Goto::node("...")
must reference an existing node by this exact name.
Sourcepub fn edge(self, from: impl Into<String>, to: impl Into<String>) -> Self
pub fn edge(self, from: impl Into<String>, to: impl Into<String>) -> Self
Add an unconditional edge. The engine uses this only when the source node returns a Goto that doesn’t specify a target (effectively, when the node returns Goto::Node(“”) or relies on a static edge). For most graphs, prefer returning Goto::Node(“…”) from inside the node.
Sourcepub fn compile(self) -> Result<CompiledGraph<S>>
pub fn compile(self) -> Result<CompiledGraph<S>>
Validate and freeze into an executable [CompiledGraph].
Source§impl<S: GraphState> Graph<S>
impl<S: GraphState> Graph<S>
Sourcepub fn linear() -> LinearBuilder
pub fn linear() -> LinearBuilder
Sugar for the linear-pipeline case. Graph::linear() returns a
LinearBuilder. The result is a CompiledGraph<()> — same engine,
same Runnable<(), ()> contract.
Source§impl<S: GraphState> Graph<S>
impl<S: GraphState> Graph<S>
Sourcepub fn from_snapshot(
snap: &GraphSnapshot,
node_factory: &NodeFactory<S>,
) -> Result<Self>
pub fn from_snapshot( snap: &GraphSnapshot, node_factory: &NodeFactory<S>, ) -> Result<Self>
Reconstruct a Graph<S> from a GraphSnapshot using a factory
to produce node implementations by name. The factory must return
a node for every name in snap.nodes; otherwise this errors.