Expand description
WAL encoding and decoding.
This module defines the encode/decode contract for WAL events with deterministic ordering and version framing policy.
§Format
The WAL encoding uses a framed binary format with CRC-32 integrity checks:
+-------------+-------------+------------+------------------------+
| Version (4B)| Length (4B) | CRC-32 (4B)| Serialized Event (N B) |
+-------------+-------------+------------+------------------------+- Version: 4-byte LE unsigned integer indicating the format version (currently 5)
- Length: 4-byte LE unsigned integer indicating the length of the serialized event
- CRC-32: 4-byte LE CRC-32 checksum of the serialized event payload
- Serialized Event: The postcard-encoded WalEvent structure
This format ensures:
- Deterministic ordering: The same event always produces the same bytes
- Version framing: future format changes can be handled by checking the version
- Length prefixing: allows efficient reading without backtracking
- Integrity: CRC-32 detects corruption in the payload
Enums§
- Decode
Error - Errors that can occur during WAL decoding.
- Encode
Error - Errors that can occur during WAL encoding.
Constants§
- HEADER_
LEN - Size of the WAL record header in bytes (version + length + crc32).
- MAX_
PAYLOAD_ SIZE - Maximum payload size that can be encoded in a WAL record.
- VERSION
- The current WAL format version.