Skip to main content

Module db

Module db 

Source
Expand description

SensorDb implementation.

Append-only sensor database for NOR flash with circular sector management.

§Usage

ⓘ
use sensor_db::{MockFlash, SensorDb};

const PAGE: usize = 256;
const SECTOR: usize = 4096;
const SECTORS: usize = 32;

let flash = MockFlash::<PAGE, SECTOR>::new(SECTORS * SECTOR);
let mut db: SensorDb<_, PAGE, SECTORS> = SensorDb::new(flash, 0, 32, 2).unwrap();
db.format().unwrap();

db.append(1, 1000, &[0xAB, 0xCD]).unwrap();
let mut buf = [0u8; 16];
let (hdr, n) = db.latest(1, &mut buf).unwrap().unwrap();
assert_eq!(&buf[..n], &[0xAB, 0xCD]);

Structs§

DbConfig
Geometry and identity of a database region.
DbStats
Statistics about the database state.
LogPosition
A position in the log: sector sequence plus byte offset within that sector.
MountStats
Statistics returned after mounting.
ReadCursor
Outcome of a SensorDb::read_from pass.
Replicated
How much one replication step carried, in both units the accounting needs.
SensorDb
Append-only sensor database for NOR flash.
SpoolStats
Replication accounting for a log.

Enums§

CompactScope
Which sealed sectors SensorDb::compact may erase.
MountMode
How much of the log to index when mounting.