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
impl ChannelState
Sourcepub fn with_channel(
self,
name: impl Into<String>,
channel: impl Channel + 'static,
) -> Self
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.
Sourcepub fn channels(&self) -> &ChannelSet
pub fn channels(&self) -> &ChannelSet
Borrows the underlying ChannelSet.
Sourcepub fn get(&self, name: &str) -> Option<&Value>
pub fn get(&self, name: &str) -> Option<&Value>
Returns the current value of channel name, if written.
Sourcepub fn snapshot(&self) -> BTreeMap<String, Value>
pub fn snapshot(&self) -> BTreeMap<String, Value>
Returns the tracked channel values (see ChannelSet::snapshot).
Sourcepub fn is_ready(&self, name: &str) -> Result<bool>
pub fn is_ready(&self, name: &str) -> Result<bool>
Whether channel name is a satisfied barrier (see
ChannelSet::is_ready).
Sourcepub fn merge(self, update: ChannelUpdate) -> Result<Self>
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
impl Clone for ChannelState
Source§fn clone(&self) -> ChannelState
fn clone(&self) -> ChannelState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ChannelState
impl Debug for ChannelState
Source§impl Default for ChannelState
impl Default for ChannelState
Source§fn default() -> ChannelState
fn default() -> ChannelState
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.
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>
fn apply( &self, state: ChannelState, update: ChannelUpdate, ) -> Result<ChannelState>
update to state, producing the new state.