Expand description
Binary format helpers shared across AOF and snapshot files.
Provides TLV-style encoding primitives, CRC32 checksums, and magic byte constants. All multi-byte integers are stored in little-endian.
Enums§
- Format
Error - Errors that can occur when reading or writing persistence formats.
Constants§
- AOF_
MAGIC - Magic bytes for the AOF file header.
- FORMAT_
VERSION - Current format version for both AOF and snapshot files.
- MAX_
FIELD_ LEN - Maximum length we’ll allocate when reading a length-prefixed field. 512 MB is generous for any realistic key or value — a corrupt or malicious length prefix won’t cause a multi-gigabyte allocation.
- SNAP_
MAGIC - Magic bytes for the snapshot file header.
Functions§
- crc32
- Computes a CRC32 checksum over a byte slice.
- read_
bytes - Reads a length-prefixed byte vector:
[len: u32][data]. - read_
f64 - Reads an
f64in little-endian. - read_
header - Reads and validates a file header. Returns an error if magic doesn’t match or version is unsupported. Returns the format version.
- read_
i64 - Reads an
i64in little-endian. - read_u8
- Reads a
u8from the reader. - read_
u16 - Reads a
u16in little-endian. - read_
u32 - Reads a
u32in little-endian. - verify_
crc32 - Verifies that
datamatches the expected CRC32 checksum. - verify_
crc32_ values - Verifies that two CRC32 values match.
- write_
bytes - Writes a length-prefixed byte slice:
[len: u32][data]. - write_
f64 - Writes an
f64in little-endian. - write_
header - Writes a file header: magic bytes + version byte.
- write_
i64 - Writes an
i64in little-endian. - write_
u8 - Writes a
u8to the writer. - write_
u16 - Writes a
u16in little-endian. - write_
u32 - Writes a
u32in little-endian.