Skip to main content

langgraph_checkpoint/
traits.rs

1use thiserror::Error;
2
3use crate::types::Checkpoint;
4
5#[derive(Debug, Error)]
6pub enum CheckpointError {
7    #[error("checkpoint conflict: `{0}`")]
8    Conflict(String),
9    #[error("storage error: {0}")]
10    Storage(String),
11}
12
13pub trait CheckpointSaver: Send + Sync {
14    fn put(&self, checkpoint: Checkpoint) -> Result<(), CheckpointError>;
15    fn get(
16        &self,
17        thread_id: &str,
18        checkpoint_id: &str,
19    ) -> Result<Option<Checkpoint>, CheckpointError>;
20    /// Returns checkpoints for a thread.
21    ///
22    /// Order is backend-defined and MUST NOT be relied on by callers.
23    fn list(&self, thread_id: &str) -> Result<Vec<Checkpoint>, CheckpointError>;
24}