Module reader

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:

  1. Inspect demand to learn how many bytes to read next (12 for a header, then length for the payload).
  2. Read exactly that many bytes from storage and pass them to feed together with the SessionState to mutate.
  3. Repeat until demand returns Demand::Stop or 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§

JournalReader
Decodes CRC-framed journal records one frame at a time.

Enums§

Demand
Describes what the I/O layer should do next.
JournalFrameError
Error returned when a journal frame cannot be decoded.
ReaderState 🔒
Step
Reports the result of feeding a chunk to the reader.