Skip to main content

Channel

Trait Channel 

Source
pub trait Channel:
    Any
    + Send
    + Sync {
    // Required methods
    fn merge(&mut self, update: Box<dyn Any + Send>);
    fn clone_box(&self) -> Box<dyn Channel>;
    fn clear(&mut self);
    fn checkpoint(&self) -> Result<Vec<u8>, PeError>;
    fn type_name(&self) -> &'static str;
    fn as_any(&self) -> &dyn Any;
    fn as_any_mut(&mut self) -> &mut dyn Any;

    // Provided method
    fn is_ephemeral(&self) -> bool { ... }
}
Expand description

Core channel trait — knows how to merge updates into itself.

Every state field is backed by a channel. The channel type determines merge semantics (overwrite, append, ephemeral, etc.).

Required Methods§

Source

fn merge(&mut self, update: Box<dyn Any + Send>)

Merge a boxed update value into this channel.

Source

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

Clone the channel (for snapshot isolation during parallel execution).

Source

fn clear(&mut self)

Clear the channel (for ephemeral values — called between supersteps).

Source

fn checkpoint(&self) -> Result<Vec<u8>, PeError>

Serialize channel state for checkpointing.

§REVIEW(002): Returns Result instead of Vec<u8>

Previously returned Vec<u8> with unwrap_or_default() on serialization failure, which would silently produce corrupt/empty checkpoint data. For a library promising durable execution, silent data loss is unacceptable. Callers must handle the error (log, retry, abort checkpoint).

Source

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

Name of this channel type (for debugging).

Source

fn as_any(&self) -> &dyn Any

Downcast support — returns self as &dyn Any.

Source

fn as_any_mut(&mut self) -> &mut dyn Any

Downcast support — returns self as &mut dyn Any.

Provided Methods§

Source

fn is_ephemeral(&self) -> bool

Whether this channel should be cleared between supersteps.

§REVIEW(002): Selective clearing

ChannelStore::clear_ephemeral() previously called clear() on ALL channels, relying on LastValue/Appender having no-op clear() impls. This is fragile: any future Channel with a meaningful clear() that shouldn’t run between supersteps would silently lose data. This method lets the store ask each channel whether it participates in superstep clearing.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§