Skip to main content

Channel

Trait Channel 

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

Required Methods§

Source

fn kind(&self) -> &'static str

A short, stable kind tag used for debugging and topology export.

Source

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.

Source

fn clone_box(&self) -> Box<dyn Channel>

Clones the channel into a fresh box (enables Clone for ChannelSet).

Provided Methods§

Source

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.

Source

fn is_ephemeral(&self) -> bool

Whether the channel’s value is cleared at the start of the next step.

Source

fn is_tracked(&self) -> bool

Whether the channel participates in ChannelSet::snapshot / durable state. Untracked returns false.

Source

fn is_ready(&self, _current: Option<&Value>) -> bool

Barrier readiness: whether the channel has received all the inputs it is waiting for. Non-barrier channels are always ready.

Trait Implementations§

Source§

impl Clone for Box<dyn Channel>

Source§

fn clone(&self) -> Self

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 Box<dyn Channel>

Source§

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

Formats the value using the given formatter. Read more

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§