pub struct RunContext<'a, S> {
pub state: &'a mut S,
pub node_id: NodeId,
pub ctx: &'a BspContext,
pub execution_no: u64,
/* private fields */
}Expand description
Everything a node may touch, nothing it may not.
The engine hands one of these to each execute call. Nodes mutate the consumer state
through RunContext::state, read gathered pin inputs, and stage pin outputs; they
never name their successors — the engine decides what happens next from the edges.
§Retry & rollback contract
When a node carries a retry policy, a failed attempt is re-invoked with the same
gathered inputs and an incremented RunContext::execution_no. A node that stages
writes into state should therefore treat execution_no > 0 as “undo my partial
writes from the previous attempt first” — that is the exactly-once-ish rollback hook.
Fields§
§state: &'a mut SThe consumer state (history, stores, metrics…). &mut, owned by the engine
between executions — required for fork/merge and suspension snapshots.
node_id: NodeIdThe id of the node being executed.
ctx: &'a BspContextDependency-injection context (unchanged from the dataflow engine).
execution_no: u64This node’s Nth execute invocation, 0-based (loop- and retry-aware).
Implementations§
Source§impl<'a, S> RunContext<'a, S>
impl<'a, S> RunContext<'a, S>
Sourcepub fn input<T: Any + Send + Sync + Clone>(&self, port: PortIndex) -> Option<T>
pub fn input<T: Any + Send + Sync + Clone>(&self, port: PortIndex) -> Option<T>
Reads a gathered input value, downcast to T, without consuming it.
Sourcepub fn input_value(&self, port: PortIndex) -> Option<&BspValue>
pub fn input_value(&self, port: PortIndex) -> Option<&BspValue>
Reads a gathered input value without consuming it.
Sourcepub fn take_input(&mut self, port: PortIndex) -> Option<BspValue>
pub fn take_input(&mut self, port: PortIndex) -> Option<BspValue>
Takes a gathered input value out of the context (dataflow profile; used by the
#[node] macros to unpack named ports).
Sourcepub fn set_output<T: Any + Send + Sync>(&mut self, port: PortIndex, value: T)
pub fn set_output<T: Any + Send + Sync>(&mut self, port: PortIndex, value: T)
Stages a typed value for an output port.
Values staged here merge with (and are overridden by) the port map returned in
crate::node::NodeOutcome::Success.
Sourcepub fn skip_outputs(&mut self)
pub fn skip_outputs(&mut self)
Marks every declared output port to be written with the BspSkip marker
(dataflow profile skip propagation), regardless of any staged outputs.