Skip to main content

ChannelState

Struct ChannelState 

Source
pub struct ChannelState { /* private fields */ }
Expand description

A concrete graph State wrapping a ChannelSet.

ChannelState implements crate::graph::StateReducer<ChannelState, ChannelUpdate> for itself, so a channel-based graph is built directly with GraphBuilder<ChannelState, ChannelUpdate> and runs on the unchanged executor: each superstep the executor folds every branch’s ChannelUpdate into the committed ChannelState through this reducer, dispatching each write to its channel’s merge rule.

The reducer’s &self receiver is unused — the merge rules travel inside the running state’s ChannelSet — so any ChannelState value (for example ChannelState::default) can be passed to set_reducer.

Implementations§

Source§

impl ChannelState

Source

pub fn new() -> Self

Creates a state with no channels.

Source

pub fn with_channel( self, name: impl Into<String>, channel: impl Channel + 'static, ) -> Self

Registers channel under name, returning the state for chaining. Use this to declare a graph’s channel schema before running.

Source

pub fn channels(&self) -> &ChannelSet

Borrows the underlying ChannelSet.

Source

pub fn get(&self, name: &str) -> Option<&Value>

Returns the current value of channel name, if written.

Source

pub fn snapshot(&self) -> BTreeMap<String, Value>

Returns the tracked channel values (see ChannelSet::snapshot).

Source

pub fn is_ready(&self, name: &str) -> Result<bool>

Whether channel name is a satisfied barrier (see ChannelSet::is_ready).

Source

pub fn merge(self, update: ChannelUpdate) -> Result<Self>

Folds a ChannelUpdate into this state, dispatching each write to its channel’s merge rule. This is the core reducer step.

When the update is stamped (via ChannelUpdate::at_step) with a step number that differs from the last one seen, the per-step write tracking is reset and Ephemeral channels are cleared before the writes apply. A second write to a non-aggregate channel within the same stamped step raises TinyAgentsError::InvalidConcurrentUpdate.

Trait Implementations§

Source§

impl Clone for ChannelState

Source§

fn clone(&self) -> ChannelState

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ChannelState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ChannelState

Source§

fn default() -> ChannelState

Returns the “default value” for a type. Read more
Source§

impl StateReducer<ChannelState, ChannelUpdate> for ChannelState

ChannelState is its own StateReducer: the &self receiver is unused (merge rules live in the running state’s ChannelSet), so any ChannelState may be passed to set_reducer.

Source§

fn apply( &self, state: ChannelState, update: ChannelUpdate, ) -> Result<ChannelState>

Applies update to state, producing the new state.

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.