Skip to main content

save_snapshot

Function save_snapshot 

Source
pub fn save_snapshot(
    snapshots_dir: &Path,
    state: &MaterializedState,
) -> Result<PathBuf>
Expand description

Save a bincode-serialized, zstd-compressed snapshot file (.snap.zst) (§5.5).

Written to a temporary file, flushed to disk, and renamed into place. A snapshot is read back with no integrity check beyond what zstd and bincode happen to notice, so a half-written file at the final name is a file that looks loadable and is not — and it would be the newest one, which is exactly the one a restart reaches for. Rename within a directory is atomic, so a crash leaves either the old snapshot or the new one, never a splice.