Skip to main content

Module reader

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:

  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 State 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 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.
FrameError
Error returned when a journal frame cannot be replayed.
ReaderState 🔒
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.