pub struct Topic<T> { /* private fields */ }Expand description
A channel that accumulates all written values.
Unlike LastValue which keeps only the most recent value, Topic appends all writes to a list. This is useful for collecting multiple results or building up a history.
§Example
use rust_langgraph::channels::{BaseChannel, Topic};
let mut channel = Topic::<String>::new();
channel.update(vec![serde_json::json!("first")]).unwrap();
channel.update(vec![serde_json::json!("second")]).unwrap();
let values: Vec<String> = serde_json::from_value(
channel.get().unwrap().unwrap()
).unwrap();
assert_eq!(values, vec!["first", "second"]);Implementations§
Trait Implementations§
Source§impl<T> BaseChannel for Topic<T>
impl<T> BaseChannel for Topic<T>
Source§fn update(&mut self, values: Vec<Value>) -> Result<()>
fn update(&mut self, values: Vec<Value>) -> Result<()>
Update the channel with new values Read more
Source§fn checkpoint(&self) -> Result<Value>
fn checkpoint(&self) -> Result<Value>
Serialize the channel state for checkpointing
Source§fn from_checkpoint(data: Value) -> Result<Box<dyn BaseChannel>>
fn from_checkpoint(data: Value) -> Result<Box<dyn BaseChannel>>
Restore the channel state from a checkpoint
Auto Trait Implementations§
impl<T> Freeze for Topic<T>
impl<T> RefUnwindSafe for Topic<T>where
T: RefUnwindSafe,
impl<T> Send for Topic<T>where
T: Send,
impl<T> Sync for Topic<T>where
T: Sync,
impl<T> Unpin for Topic<T>where
T: Unpin,
impl<T> UnsafeUnpin for Topic<T>
impl<T> UnwindSafe for Topic<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