Module reader
Available on crate feature
alloc only.Expand description
Sans-io journal replay.
Reader 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 theStateto 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 have the whole journal in memory,
Reader::replay_slice runs the state machine over a &[u8] and
applies every valid frame.
Structs§
- Reader
- Decodes CRC-framed journal records one frame at a time.
Enums§
- Demand
- Describes what the I/O layer should do next.
- Frame
Error - Error returned when a journal frame cannot be replayed.
- Reader
State 🔒 - Step
- Reports the result of feeding a chunk to the reader.
Functions§
- apply_
v1 🔒 - Applies a frame of ops in the version 1 layout, all or nothing on a decode error.