umsh_journal_store/lib.rs
1//! Power-loss-safe two-page record journals shared by every UMSH
2//! device board.
3//!
4//! Extracted from the nRF device firmware so the ESP32-S3 port
5//! reuses the same tested machinery. Three journal record formats ride
6//! one shared engine:
7//!
8//! * [`record`] — the engine: the [`record::RecordWriter`] /
9//! [`record::PageEraser`] flash traits, the body-first/commit-word-last
10//! committed write, CRC32, and wraparound-safe generation comparison.
11//! * [`ble`] — fixed-size BLE security snapshots (pairing PIN, local
12//! IRK, bonds).
13//! * [`proto`] — variable-payload protocol records: opaque session
14//! snapshots, the device identity, and clear tombstones.
15//! * [`counter`] — the device node's frame-counter map, serialized as
16//! one whole-map [`proto`] payload per flush.
17//!
18//! Flash **addresses** deliberately live with each firmware, not here:
19//! which pages a journal owns is a memory-map fact (`memory.x` on nRF,
20//! the partition table on ESP32). Structural constants — slot sizes,
21//! payload bounds, the 4 KiB page size both chips share — are this
22//! crate's.
23//!
24//! Mount scans and write-target rotation are not here either, but they
25//! are no longer per-firmware: they live in `umsh-ulcp-runtime`'s
26//! `journal` module, generic over a board's flash via the
27//! [`record::RecordWriter`] / [`record::PageEraser`] /
28//! [`record::RecordReader`] traits. A board implements those three for
29//! its own flash type — which is where each chip's quirks stay, such as
30//! blocking NVMC reads under MPSL on nRF and the fault-injection hooks.
31#![no_std]
32
33#[cfg(test)]
34extern crate std;
35
36pub mod ble;
37pub mod counter;
38pub mod proto;
39pub mod record;