pub struct TopicChannel<T> { /* private fields */ }Expand description
Topic channel: accumulates all published values into a list
This channel implements pub/sub messaging patterns where all writes are accumulated into a list. Each value is appended independently, allowing multiple publishers to send messages to the same topic.
§Type Parameters
T- The message type stored in the topic
§Examples
use juncture_core::state::channel::TopicChannel;
let mut channel: TopicChannel<String> = TopicChannel::new();
// Publish messages
channel.update(vec!["hello".to_string()]);
channel.update(vec!["world".to_string()]);
// Get all accumulated messages
let messages = channel.get();
assert_eq!(messages.len(), 2);
assert_eq!(messages[0], "hello");
assert_eq!(messages[1], "world");
// Reset for next superstep
channel.reset();
assert!(messages.is_empty());Implementations§
Source§impl<T> TopicChannel<T>
impl<T> TopicChannel<T>
Trait Implementations§
Source§impl<T> Channel<Vec<T>> for TopicChannel<T>
impl<T> Channel<Vec<T>> for TopicChannel<T>
Source§fn update(&mut self, values: Vec<Vec<T>>) -> bool
fn update(&mut self, values: Vec<Vec<T>>) -> bool
Update the channel with new values. Returns true if the value changed.
Source§fn consume(&mut self) -> bool
fn consume(&mut self) -> bool
Check if the channel has been consumed (for trigger-based activation)
Source§fn checkpoint(&self) -> Option<Value>
fn checkpoint(&self) -> Option<Value>
Create a checkpoint of the current value for persistence
Source§impl<T: Clone> Clone for TopicChannel<T>
impl<T: Clone> Clone for TopicChannel<T>
Source§fn clone(&self) -> TopicChannel<T>
fn clone(&self) -> TopicChannel<T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Debug> Debug for TopicChannel<T>
impl<T: Debug> Debug for TopicChannel<T>
Source§impl<T> Default for TopicChannel<T>
impl<T> Default for TopicChannel<T>
Auto Trait Implementations§
impl<T> Freeze for TopicChannel<T>
impl<T> RefUnwindSafe for TopicChannel<T>where
T: RefUnwindSafe,
impl<T> Send for TopicChannel<T>where
T: Send,
impl<T> Sync for TopicChannel<T>where
T: Sync,
impl<T> Unpin for TopicChannel<T>where
T: Unpin,
impl<T> UnsafeUnpin for TopicChannel<T>
impl<T> UnwindSafe for TopicChannel<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more