Module reader
Available on crate feature
alloc only.Expand description
Sans-io journal replay.
JournalReader is an incremental, sans-io state machine that decodes
CRC-framed journal bytes one frame at a time. The I/O layer drives it
without ever buffering the entire journal in memory:
- Inspect
demandto learn how many bytes to read next (12 for a header, thenlengthfor the payload). - Read exactly that many bytes from storage and pass them to
feedtogether with theSessionStateto mutate. - Repeat until
demandreturnsDemand::Stopor the source signals EOF.
On a clean shutdown the source’s length equals
bytes_consumed. On a crash the tail
may be truncated mid-frame. Truncate the source to
bytes_consumed to self-heal.
For callers that already hold the whole journal in memory,
JournalReader::replay_slice is a convenience that drives the state
machine over a &[u8] and applies every valid frame.
Structs§
- Journal
Reader - Decodes CRC-framed journal records one frame at a time.
Enums§
- Demand
- Describes what the I/O layer should do next.
- Journal
Frame Error - Error returned when a journal frame cannot be decoded.
- Reader
State 🔒 - Step
- Reports the result of feeding a chunk to the reader.