Expand description
checkpointkit persists serializable state atomically and provides a
lightweight progress tracker that can resume after crashes.
§Examples
use checkpointkit::{load, save};
use serde::{Deserialize, Serialize};
use tempfile::tempdir;
#[derive(Debug, Serialize, Deserialize, PartialEq)]
struct State {
done: u64,
}
let dir = tempdir().unwrap();
let path = dir.path().join("checkpoint.json");
save(&path, &State { done: 4 }).unwrap();
let state: State = load(&path).unwrap().unwrap();
assert_eq!(state, State { done: 4 });Structs§
- Progress
Tracker - Progress tracker that persists state through checkpoints. Progress tracker persisted through a checkpoint file.
Enums§
- Checkpoint
Error - Error type returned by checkpoint operations. Errors returned by checkpoint operations.
Functions§
- atomic_
write - Atomic load/save functions for checkpoint state.
Atomically writes raw bytes to
pathusing a unique temp file + rename. - load
- Atomic load/save functions for checkpoint state.
Loads serializable state from
path, returningOk(None)when no checkpoint exists. - save
- Atomic load/save functions for checkpoint state.
Saves serializable state to
pathusing unique temp file + rename for atomic replacement.