Module journal

Module journal 

Available on crate feature alloc only.
Expand description

Append-only session operation log and its CRC-framed encoding.

This module provides the building blocks for durable session state. It is organised as a sans-io toolkit with no knowledge of files or async:

  • JournaledSession wraps an InMemorySession and records every mutation as a SessionOp. The persistence layer decides how to store those ops: framed bytes for a file, rows for a SQL store.
  • encode_frames turns recorded ops into CRC-framed bytes.
  • JournalReader decodes those bytes one frame at a time, either streaming from external storage or in-memory.
  • Header is the file-level header that identifies the on-disk format version, written once before any frames.

ModulesΒ§

crc32 πŸ”’
CRC-32/ISO-HDLC (IEEE 802.3) checksum.
encode πŸ”’
frame πŸ”’
header πŸ”’
reader πŸ”’
Sans-io journal replay.

StructsΒ§

Header
A parsed, supported journal file header.
JournalReader
Decodes CRC-framed journal records one frame at a time.
JournaledSession
A SessionState wrapper that records every mutation as a SessionOp.

EnumsΒ§

Demand
Describes what the I/O layer should do next.
HeaderError
Why a byte sequence is not a valid, supported journal file header.
JournalFrameError
Error returned when a journal frame cannot be decoded.
Step
Reports the result of feeding a chunk to the reader.

FunctionsΒ§

encode_frames
Encodes ops as a single CRC frame, appending it to out.
snapshot_ops
Encodes the entire current state of session as a sequence of β€œstore” ops.