pub struct Command<S: State> {
pub update: Option<S::Update>,
pub goto: Goto,
pub graph: GraphTarget,
pub resume: Option<ResumeValue>,
pub stream_data: Vec<Value>,
}Expand description
Command: node return value combining state update and routing
Nodes can return S::Update (simple case) or Command<S> (for routing control).
Fields§
§update: Option<S::Update>State update to apply
goto: GotoRouting instruction
graph: GraphTargetTarget graph (current or parent)
resume: Option<ResumeValue>Resume value for HITL interrupt resumption
When provided, this value is used to resume from a previously triggered
interrupt. Supports single values, ID-based mapping, and namespace-based
mapping via ResumeValue.
stream_data: Vec<Value>Custom streaming data to emit during execution
Nodes can attach arbitrary JSON values here that will be emitted as
[StreamEvent::Custom] events during graph execution. Each entry in
the vector produces one custom stream event tagged with the emitting
node name. Use Command::with_stream_data to append items.
Implementations§
Source§impl<S: State> Command<S>
impl<S: State> Command<S>
Sourcepub fn update_and_goto(update: S::Update, target: impl Into<String>) -> Self
pub fn update_and_goto(update: S::Update, target: impl Into<String>) -> Self
Create command with update and routing
Sourcepub const fn send(targets: Vec<SendTarget>) -> Self
pub const fn send(targets: Vec<SendTarget>) -> Self
Create command with dynamic fan-out
Sourcepub const fn update_and_send(
update: S::Update,
targets: Vec<SendTarget>,
) -> Self
pub const fn update_and_send( update: S::Update, targets: Vec<SendTarget>, ) -> Self
Create command with update and fan-out
Sourcepub fn goto_parent(target: impl Into<String>) -> Self
pub fn goto_parent(target: impl Into<String>) -> Self
Create command that routes to parent graph
Sourcepub fn with_resume(self, value: ResumeValue) -> Self
pub fn with_resume(self, value: ResumeValue) -> Self
Attach a resume value to this command
Sourcepub fn with_stream_data(self, data: Value) -> Self
pub fn with_stream_data(self, data: Value) -> Self
Attach custom streaming data to this command
The given value is appended to the command’s streaming data list.
During graph execution, each entry is emitted as a
[StreamEvent::Custom] event, allowing nodes to push custom JSON
payloads to the stream consumer alongside state updates and routing.
§Examples
use juncture_core::Command;
use serde_json::json;
// In a node returning Command:
Command::end().with_stream_data(json!({"progress": 0.75}));