Skip to main content

Crate checkpointkit

Crate checkpointkit 

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

ProgressTracker
Progress tracker that persists state through checkpoints. Progress tracker persisted through a checkpoint file.

Enums§

CheckpointError
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 path using a unique temp file + rename.
load
Atomic load/save functions for checkpoint state. Loads serializable state from path, returning Ok(None) when no checkpoint exists.
save
Atomic load/save functions for checkpoint state. Saves serializable state to path using unique temp file + rename for atomic replacement.