ministate 0.1.1

A minimal, embeddable state manager with durable WAL logging and optional snapshot support. Ideal for component registries, metadata stores, and local state machines in edge applications.
Documentation

ministate

Minimal state manager with durable WAL logging
Part of the mini-rs embeddable toolkit

crates.io
docs.rs
License: Apache-2.0/MIT

ministate gives you just enough: crash-safe, in-memory state with replayable history.


🎯 Purpose

ministate provides a simple yet robust way to maintain mutable application state that survives process restarts, using an append-only Write-Ahead Log (WAL) built on ministore.

Key features:

  • ✅ In-memory state — fast reads via RwLock, full Clone on demand.
  • ✅ Durable mutations — every change is fsynced before being applied.
  • ✅ Crash recovery — full state restored by replaying WAL on startup.
  • ✅ Logical sequencing — each mutation gets a monotonically increasing sequence number.
  • ✅ Optional snapshots — enable snapshot feature for faster recovery (via minisnap).

Perfect for:

  • Component/deployment registries (e.g., in Arcella)
  • Queue metadata (e.g., in walmq)
  • Local coordination primitives (leader election, locks)
  • Embedded/IoT apps requiring crash-safe state

📦 Quick Start

Basic (WAL-only)

[dependencies]

ministate = "0.1"

serde = { version = "1.0", features = ["derive"] }

use ministate::{Mutator, StateManager};
use serde::{Deserialize, Serialize};

#[derive(Default, Clone, Serialize, Deserialize)]
struct Counter { value: u32 }

#[derive(Serialize, Deserialize)]
struct Inc { by: u32 }

impl Mutator<Counter> for Inc {
    fn apply(&self, state: &mut Counter) {
        state.value += self.by;
    }
}

let mgr = StateManager::open("./state", "counter.wal.jsonl").await?;
mgr.apply(Inc { by: 10 }).await?;
assert_eq!(mgr.snapshot().await.value, 10);

With Snapshots (opt-in)

[dependencies]

ministate = { version = "0.1", features = ["snapshot"] }

minisnap = "0.1"

mgr.create_snapshot().await?; // saves state + sequence number

✅ Guarantees

Guarantee Description
Durability If apply().await returns Ok, the mutation is on disk.
Atomicity In-memory state is updated only after WAL write succeeds.
Ordering Mutations applied in exact WAL order.
Recoverability Full state restored from WAL (or WAL + snapshot).

🧩 Part of mini-rs

  • ministore — durable WAL engine
  • minisnap — optional snapshot & log compaction support
  • ministate — state manager (this crate)
  • miniqueue — durable message queue (in development)

Used in:

  • Arcella — component and deployment state
  • walmq — message queue metadata

📄 License

Dual-licensed under:

  • Apache License 2.0
  • MIT License

Choose the one that best fits your project.


ministate — because state should be simple, durable, and recoverable.
Part of the mini-rs family: simple, embeddable, reliable.