Skip to main content

CheckpointStore

Trait CheckpointStore 

Source
pub trait CheckpointStore<S> {
    // Required methods
    fn save(&self, checkpoint: Checkpoint<S>) -> Result<(), FoldError>
       where S: Clone + Serialize;
    fn load(&self, id: &str) -> Result<Option<Checkpoint<S>>, FoldError>
       where S: Clone + Serialize;
    fn load_latest(
        &self,
        prefix: &str,
    ) -> Result<Option<Checkpoint<S>>, FoldError>
       where S: Clone + Serialize;
    fn delete(&self, id: &str) -> Result<(), FoldError>;
    fn list(&self) -> Result<Vec<String>, FoldError>;
}
Expand description

Trait for checkpoint persistence backends.

The key is the checkpoint id string. load_latest returns the checkpoint whose prefix matches — defined as all checkpoints whose id starts with the given prefix, selecting the most recently created. Ties on created_at are broken by uuid (lexicographic) for determinism.

Required Methods§

Source

fn save(&self, checkpoint: Checkpoint<S>) -> Result<(), FoldError>
where S: Clone + Serialize,

Persist a checkpoint, computing and storing an integrity hash.

Source

fn load(&self, id: &str) -> Result<Option<Checkpoint<S>>, FoldError>
where S: Clone + Serialize,

Load a checkpoint by its exact id, verifying the integrity hash.

Returns Ok(None) when no checkpoint with that id exists. Returns Err(FoldError::IntegrityMismatch) if the stored hash does not match the recomputed hash of the loaded state.

Source

fn load_latest(&self, prefix: &str) -> Result<Option<Checkpoint<S>>, FoldError>
where S: Clone + Serialize,

Load the most recently created checkpoint whose id starts with prefix.

Ties on created_at are broken by uuid for determinism. Returns None when no checkpoints match the prefix.

Source

fn delete(&self, id: &str) -> Result<(), FoldError>

Delete the checkpoint with the given id.

Returns Err(FoldError::CheckpointNotFound) if no checkpoint with that id exists.

Source

fn list(&self) -> Result<Vec<String>, FoldError>

List all checkpoint id strings currently stored.

The order is unspecified; callers should sort if a stable order is needed.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§