Skip to main content

StepCtx

Struct StepCtx 

Source
pub struct StepCtx<'a> {
    pub node_id: &'a str,
    pub run_id: &'a str,
    pub input: &'a Value,
    pub turn: usize,
    pub results: &'a [EffectResult],
    pub history: &'a [Vec<EffectResult>],
}
Expand description

What the runtime tells a step about where it is.

Deliberately small. A step’s own reasoning state belongs in the value it carries, not here — that is what makes replay work: re-polling with the same journal reproduces the same decisions.

Fields§

§node_id: &'a str

This node’s id in the graph.

§run_id: &'a str

The run this belongs to.

§input: &'a Value

Input resolved from predecessors.

§turn: usize

Which turn this is, counting from 0. Part of the journal key, so a step that asks the same question twice gets two recorded answers.

§results: &'a [EffectResult]

Results of the effects requested last turn, in request order. Empty on turn 0.

§history: &'a [Vec<EffectResult>]

Every turn’s results so far, oldest first.

A step that accumulates — a conversation, a running total — rebuilds it from here rather than holding it in self. That is what keeps replay honest: the history is replayed identically, so the same decisions follow, whereas hidden state would not survive a restart.

Implementations§

Source§

impl<'a> StepCtx<'a>

Source

pub fn new( node_id: &'a str, run_id: &'a str, input: &'a Value, turn: usize, ) -> Self

A context with no results yet — what a first poll sees. Later turns attach theirs with Self::with_history or Self::with_results.

Source

pub fn with_history(self, history: &'a [Vec<EffectResult>]) -> Self

Set the full history; results becomes its last entry.

Source

pub fn with_results(self, results: &'a [EffectResult]) -> Self

Set only the current turn’s results — for tests and single-turn steps.

Source

pub fn result(&self) -> Option<&EffectResult>

The single result of a one-effect turn.

Source

pub fn all_results(&self) -> impl Iterator<Item = &EffectResult>

Every result from every turn, oldest first, flattened.

Auto Trait Implementations§

§

impl<'a> Freeze for StepCtx<'a>

§

impl<'a> RefUnwindSafe for StepCtx<'a>

§

impl<'a> Send for StepCtx<'a>

§

impl<'a> Sync for StepCtx<'a>

§

impl<'a> Unpin for StepCtx<'a>

§

impl<'a> UnsafeUnpin for StepCtx<'a>

§

impl<'a> UnwindSafe for StepCtx<'a>

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> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

The receiver as &dyn Any, ready for downcast_ref.
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, 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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.