Expand description
Checkpoint-based state recovery system.
This module provides mechanisms for saving and restoring system state to enable crash recovery and resilience. Checkpoints can be created periodically and restored after a failure.
§Example
use chie_core::checkpoint::{CheckpointManager, CheckpointConfig, Checkpointable};
use std::path::PathBuf;
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Clone)]
struct MyState {
counter: u64,
name: String,
}
impl Checkpointable for MyState {
fn checkpoint_id(&self) -> String {
format!("mystate_{}", self.counter)
}
}
let config = CheckpointConfig {
base_path: PathBuf::from("/tmp/checkpoints"),
max_checkpoints: 5,
compression_enabled: true,
};
let mut manager = CheckpointManager::new(config)?;
let state = MyState {
counter: 42,
name: "test".to_string(),
};
// Save checkpoint
manager.save_checkpoint(&state)?;
// Restore latest checkpoint
let restored: MyState = manager.restore_latest()?;
assert_eq!(restored.counter, 42);Structs§
- Checkpoint
Config - Configuration for checkpoint management.
- Checkpoint
Manager - Manages checkpoint creation and restoration.
- Checkpoint
Metadata - Metadata about a checkpoint.
Enums§
- Checkpoint
Error - Checkpoint error types.
Traits§
- Checkpointable
- Trait for objects that can be checkpointed.