Skip to main content

Module journal

Module journal 

Available on crate feature alloc only.
Expand description

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

Durable session state is built from the parts below. They form a sans-io toolkit that does not use files or async:

  • JournaledSession wraps an InMemory and records every mutation as a Op. The persistence layer chooses how to store those ops, for example as framed bytes in a file or rows in a SQL store.
  • encode_frames turns recorded ops into CRC-framed bytes.
  • Reader 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 πŸ”’
log πŸ”’
reader πŸ”’
Sans-io journal replay.

StructsΒ§

Header
A parsed, supported journal file header.
JournaledSession
A State wrapper that records every mutation as a Op.
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.
HeaderError
Error returned when a byte sequence is not a valid, supported journal file header.
IncompleteLog
The journal could not record an op. The pending ops no longer describe every change.
Step
Reports the result of feeding a chunk to the reader.

FunctionsΒ§

encode_frames
Encodes ops as one CRC frame into sink.
snapshot_ops
Encodes the entire current state of session as a sequence of β€œstore” ops.