Skip to main content

Module page

Module page 

Source
Expand description

Page primitives: the fixed page size, the strongly-typed page id, and the owned page buffer.

All multi-byte integers in the on-disk page format are little-endian; this module is the single place that knows that fact for the M2 pager. Encoders and decoders for individual page bodies live next to their owners (header in super::header, freelist in super::freelist).

Structs§

Page
An owned, page-sized buffer. Lives in the cache’s Vec<Frame> and is reused across loads — the pager never allocates a new Page on the read hot path (Rule 3).
PageId
Identifier of a page in a database file.

Constants§

ENCRYPTION_OVERHEAD
Phase 4 (issue #9): per-page on-disk overhead added by the encryption layer (24-byte XChaCha20-Poly1305 nonce + 16-byte Poly1305 tag = 40 bytes). Defined as a public constant in pager::page so callers that don’t link the encryption Cargo feature can still reason about the encrypted physical stride (e.g. recovery tools that need to compute file offsets without invoking any crypto). Kept in lock-step with crypto::ENCRYPTION_OVERHEAD (24-byte nonce + 16-byte tag).
PAGE_SIZE
Page size in bytes. Fixed at 4 KiB for format version 0 (see docs/format.md). Parameterising this is deferred to a future milestone; the header reserves the byte for it.
PAGE_TRAILER_SIZE
Number of bytes a CRC32C page trailer occupies. The trailer is written by super::Pager::write_page in milestone M3 issue #6; at issue #5 the trailing four bytes are reserved.

Functions§

physical_offset_for
Phase 4 (issue #9): byte offset of page raw_id’s on-disk slot for a file with the given feature_flags.
physical_page_stride
Phase 4 (issue #9): physical-stride helper. Returns the on-disk size of a single non-header page given the file’s feature_flags bit-set: