Module checkpoint

Module checkpoint 

Source
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§

CheckpointConfig
Configuration for checkpoint management.
CheckpointManager
Manages checkpoint creation and restoration.
CheckpointMetadata
Metadata about a checkpoint.

Enums§

CheckpointError
Checkpoint error types.

Traits§

Checkpointable
Trait for objects that can be checkpointed.