pub trait Channel: Send + Sync {
// Required methods
fn kind(&self) -> &'static str;
fn merge(&self, current: Option<Value>, incoming: Value) -> Result<Value>;
fn clone_box(&self) -> Box<dyn Channel>;
// Provided methods
fn allows_concurrent(&self) -> bool { ... }
fn is_ephemeral(&self) -> bool { ... }
fn is_tracked(&self) -> bool { ... }
fn is_ready(&self, _current: Option<&Value>) -> bool { ... }
}Expand description
A single named state channel: it owns the merge rule that folds an incoming update value into the channel’s current value at a superstep boundary.
Channels are object-safe and value-typed (serde_json::Value) so a
ChannelSet can hold a heterogeneous map of Box<dyn Channel>. Each
channel decides:
Channel::merge— how an incoming write combines with the current value.Channel::allows_concurrent— whether two branches in the same step may both write this channel (aggregates: yes; last-value: no, seecrate::TinyAgentsError::InvalidConcurrentUpdate).Channel::is_ephemeral— whether the value is cleared at the start of the next step (one-shot channels).Channel::is_tracked— whether the value appears inChannelSet::snapshotand is considered part of durable state.Channel::is_ready— barrier readiness (defaults to always ready).
Required Methods§
Sourcefn kind(&self) -> &'static str
fn kind(&self) -> &'static str
A short, stable kind tag used for debugging and topology export.
Sourcefn merge(&self, current: Option<Value>, incoming: Value) -> Result<Value>
fn merge(&self, current: Option<Value>, incoming: Value) -> Result<Value>
Folds incoming into the channel’s current value, returning the new
value. current is None the first time the channel is written.
Takes current by value so accumulating channels (topics, barriers,
message logs) can reuse the existing backing Vec/Map in place instead
of cloning the entire accumulated value on every merge, which was
O(existing) allocation per write.
Sourcefn clone_box(&self) -> Box<dyn Channel>
fn clone_box(&self) -> Box<dyn Channel>
Clones the channel into a fresh box (enables Clone for ChannelSet).
Provided Methods§
Sourcefn allows_concurrent(&self) -> bool
fn allows_concurrent(&self) -> bool
Whether more than one concurrent branch may write this channel within a
single superstep. Aggregates (append/fold/accumulate/barrier) return
true; overwrite-style channels return false and trigger
crate::TinyAgentsError::InvalidConcurrentUpdate on a same-step clash.
Sourcefn is_ephemeral(&self) -> bool
fn is_ephemeral(&self) -> bool
Whether the channel’s value is cleared at the start of the next step.
Sourcefn is_tracked(&self) -> bool
fn is_tracked(&self) -> bool
Whether the channel participates in ChannelSet::snapshot / durable
state. Untracked returns false.
Trait Implementations§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".