pub struct CheckpointManager { /* private fields */ }Expand description
Manages file-based checkpoints for one or more workflows.
Each checkpoint is persisted as a JSON file named
<storage_dir>/<workflow_id>.checkpoint.json.
Implementations§
Source§impl CheckpointManager
impl CheckpointManager
Sourcepub fn new(storage_dir: PathBuf) -> Self
pub fn new(storage_dir: PathBuf) -> Self
Creates a new manager that stores checkpoints under storage_dir.
The directory is created on first use (lazily), so it does not need to exist at construction time.
Sourcepub fn storage_dir(&self) -> &PathBuf
pub fn storage_dir(&self) -> &PathBuf
Returns the storage directory path.
Sourcepub fn save(&self, checkpoint: &WorkflowCheckpoint) -> Result<()>
pub fn save(&self, checkpoint: &WorkflowCheckpoint) -> Result<()>
Serialises checkpoint to JSON and writes it to disk.
Overwrites any previously saved checkpoint for the same workflow_id.
§Errors
Returns WorkflowError::Io if the file cannot be written, or
WorkflowError::Serialization if JSON serialisation fails.
Sourcepub fn load(&self, workflow_id: &str) -> Result<WorkflowCheckpoint>
pub fn load(&self, workflow_id: &str) -> Result<WorkflowCheckpoint>
Reads and deserialises the checkpoint for workflow_id from disk.
§Errors
Returns WorkflowError::FileNotFound if no checkpoint exists, or
WorkflowError::Io / WorkflowError::Serialization on read/parse
failure.
Sourcepub fn delete(&self, workflow_id: &str) -> Result<()>
pub fn delete(&self, workflow_id: &str) -> Result<()>
Deletes the checkpoint file for workflow_id.
Returns Ok(()) even if no checkpoint file existed.
§Errors
Returns WorkflowError::Io if the file exists but cannot be removed.
Sourcepub fn exists(&self, workflow_id: &str) -> bool
pub fn exists(&self, workflow_id: &str) -> bool
Returns true if a checkpoint file exists for workflow_id.
Sourcepub fn list_checkpoints(&self) -> Result<Vec<String>>
pub fn list_checkpoints(&self) -> Result<Vec<String>>
Returns the workflow IDs of all checkpoints currently on disk.
Scans storage_dir for files matching *.checkpoint.json and strips
the suffix to produce the workflow ID. Files that do not parse as
valid checkpoints are silently skipped.
§Errors
Returns WorkflowError::Io if the storage directory cannot be read.
Trait Implementations§
Source§impl Clone for CheckpointManager
impl Clone for CheckpointManager
Source§fn clone(&self) -> CheckpointManager
fn clone(&self) -> CheckpointManager
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more