Expand description
durability: crash-consistent persistence primitives.
Scope:
- directory abstraction (
Directory) - on-disk framing constants (
formats) - append-only record log (
recordlog) - generic write-ahead log (
walog) - CRC-validated checkpoint snapshots (
checkpoint) - generic recovery (
recover::recover_with_wal) and segment-specific recovery (recover,publish)
§Contract (what you can rely on)
This crate is designed around two different “strength levels”:
- Crash-consistent + integrity-checked (default)
- Detects corruption (CRC/magic/version/type mismatches) and errors loudly.
- Supports best-effort recovery of a torn tail (partial record write) in the final log segment.
- Guarantees a prefix property under best-effort replay: recovered operations are a prefix of the successfully written operation stream (no garbage / no reordering).
- Stable-storage durability (opt-in)
- Requires explicit barriers (
fsync/sync_all) and sometimes parent directory sync. - Use
storage::sync_file/storage::sync_parent_dirandflush_and_sync()helpers where you need “survives power loss after success” semantics.
- Requires explicit barriers (
Terminology:
flush()is a visibility boundary, not a stable-storage guarantee.- “Best-effort” is intentionally narrow; it never masks corruption.
Note: this crate intentionally exposes traits and framing.
Higher-level crates generally decide directory layout, naming, and lifecycle policies,
but some primitives (notably walog) assume a conventional wal/ directory.
Re-exports§
pub use error::PersistenceError;pub use error::PersistenceResult;pub use storage::Directory;pub use storage::DurableDirectory;pub use storage::FsDirectory;pub use storage::MemoryDirectory;
Modules§
- checkpoint
- Generic checkpoint file (single snapshot blob).
- error
- Error types for
durability. - publish
- Crash-safe checkpoint publishing and WAL truncation helpers.
- recordlog
- Append-only record log (generic WAL primitive).
- recover
- Crash recovery using checkpoint + WAL replay.
- storage
- Storage abstraction for durability.
- walog
- Write-ahead log (WAL) for incremental updates.