Skip to main content

RunContext

Struct RunContext 

Source
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 S

The consumer state (history, stores, metrics…). &mut, owned by the engine between executions — required for fork/merge and suspension snapshots.

§node_id: NodeId

The id of the node being executed.

§ctx: &'a BspContext

Dependency-injection context (unchanged from the dataflow engine).

§execution_no: u64

This node’s Nth execute invocation, 0-based (loop- and retry-aware).

Implementations§

Source§

impl<'a, S> RunContext<'a, S>

Source

pub fn input<T: Any + Send + Sync + Clone>(&self, port: PortIndex) -> Option<T>

Reads a gathered input value, downcast to T, without consuming it.

Source

pub fn input_value(&self, port: PortIndex) -> Option<&BspValue>

Reads a gathered input value without consuming it.

Source

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).

Source

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.

Source

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.

Auto Trait Implementations§

§

impl<'a, S> !RefUnwindSafe for RunContext<'a, S>

§

impl<'a, S> !UnwindSafe for RunContext<'a, S>

§

impl<'a, S> Freeze for RunContext<'a, S>

§

impl<'a, S> Send for RunContext<'a, S>
where &'a mut S: Send,

§

impl<'a, S> Sync for RunContext<'a, S>
where &'a mut S: Sync,

§

impl<'a, S> Unpin for RunContext<'a, S>

§

impl<'a, S> UnsafeUnpin for RunContext<'a, S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more