Expand description
WAL frame encode / decode helpers.
Byte layout is documented in docs/format.md § Write-ahead log.
This module is the single place that knows it; the parent
super::Wal only calls into the helpers exposed here.
Structs§
- Frame
Header - In-memory representation of a WAL frame header.
Enums§
- Frame
Decode - Classified outcome of decoding a single WAL frame. Pass-2 of recovery
distinguishes “torn tail / stale generation” (silently discarded)
from “CRC mismatch in a frame that should have been valid” (which
surfaces as
Error::WalCorruption). Seedocs/format.md§ Recovery semantics.
Constants§
- FRAME_
AEAD_ SUFFIX_ SIZE - Phase 4 (issue #9): per-frame AEAD suffix length for encrypted
WALs (24-byte XChaCha20-Poly1305 nonce + 16-byte Poly1305 tag = 40
bytes). Frames in encrypted WALs are
FRAME_SIZE + FRAME_AEAD_SUFFIX_SIZE = 4200bytes on disk; the extra bytes sit AFTER the ciphertext body. - FRAME_
HEADER_ SIZE - Fixed size of a per-frame header (preceding the page body).
- FRAME_
SIZE - Per-frame size on disk for a plaintext WAL: header + page body. Equal to 4160 bytes.
- FRAME_
SIZE_ ENCRYPTED - Phase 4 (issue #9): per-frame size on disk for an encrypted WAL.
- WAL_
HEADER_ SIZE - Fixed size of the WAL file header. See
docs/format.md§ Write- ahead log → WAL header. - WAL_
MAGIC - File magic for the WAL header. ASCII
OBJW.
Functions§
- decode_
frame_ header - Decode and validate a frame from
buf. ReturnsNoneif the CRC does not validate, if the salt does not matchexpected_salt, or if reserved bytes are non-zero. - decode_
frame_ header_ classified - Classify a single frame buffer. The buffer length must equal
FRAME_SIZE; otherwiseFrameDecode::Malformedis returned. - encode_
frame_ header - Encode
headerinto the firstFRAME_HEADER_SIZEbytes ofbufAND compute the per-frame CRC32C covering the frame header (with the CRC field zeroed) plus the page body that follows. - frame_
offset - Byte offset of the frame at index
frame_index(0-based, where 0 is the first frame after the WAL header). - frame_
size_ for - Phase 4 (issue #9): pick the right per-frame size given the
encryptedflag.