ministore
Minimal snapshot store for durable state managers
Part of the mini-rs embeddable toolkit
minisnapgives you just enough: atomic, human-readable snapshots with zero hidden machinery.
๐ฏ Purpose
minisnap provides a simple, reliable way to serialize and restore a full copy of your application state to and from disk. It is designed to complement WAL-based systems like ministore and ministate by enabling:
- โ Fast recovery (skip replaying a long WAL)
- ๐ Consistency tracking via logical sequence numbers
- ๐งช Human-readable snapshots (plain JSON + text metadata)
- ๐ Future WAL compaction (truncate log after snapshot)
Snapshots are explicit โ you decide when to create them. No background threads. No magic.
๐ฆ Quick Start
Add to Cargo.toml
[]
= "0.1"
= { = "1.0", = ["derive"] }
Basic Usage
use SnapStore;
use ;
async
๐ก Snapshots are stored as two files:
snapshot.jsonโ serialized state (pretty-printed JSON)snapshot.seqโ plain-text sequence number (e.g.,10)
โจ Features
- Atomic writes: Temporary files +
rename()ensure snapshots are never partial. - Type-safe: Fully integrates with
serde; errors are explicit. - Filesystem-safe: Works on any POSIX-compliant filesystem (ext4, XFS, APFS, etc.).
- Zero dependencies beyond
serdeandtokio(onlyfsandio-utilfeatures). - < 200 lines of core logic โ easy to audit and understand.
๐ Integration
minisnap is optionally used by ministate when the snapshot Cargo feature is enabled:
= { = "0.1", = ["snapshot"] }
This allows ministate to:
- Save snapshots via
StateManager::create_snapshot() - (Future) Recover from snapshot + tail of WAL
- (Future) Compact WAL safely
๐ก Guarantees
| Property | Guarantee |
|---|---|
| Durability | After create().await, snapshot is on disk (fsync is implicit in tokio::fs::write + atomic rename on most systems). |
| Atomicity | Readers always see either the old snapshot or the new one โ never a corrupt intermediate state. |
| Consistency | Each snapshot is paired with a user-provided sequence number (e.g., last applied WAL index). |
โ ๏ธ Note: Atomic rename is not guaranteed on FAT32 or some network filesystems. Use on reliable local storage.
๐งช Testing & Reliability
- Full test coverage for happy and error paths
- Integration-tested with
ministate - Used in Arcella (modular WebAssembly platform) and walmq (WAL-based message queue)
๐ License
Dual-licensed under:
- Apache License 2.0
- MIT License
Choose the one that best fits your project.
minisnapโ because sometimes, the best state is the one you can trust after a crash.
Part of themini-rsfamily: simple, embeddable, reliable.