Skip to main content

decode_page_v1

Function decode_page_v1 

Source
pub fn decode_page_v1(disk: &Page, page_id: u64) -> Result<Page>
Expand description

Phase 3 (issue #8): decode a 4096-byte on-disk page from a format_minor = 1 file into its raw 4092-byte body representation (with a v0 trailer re-stamped so downstream consumers that call page_trailer_valid continue to work).

Verifies the v1 trailer FIRST (Rule 2: CRC before decompress); a CRC mismatch returns Error::Corruption { page_id } without invoking LZ4. The LZ4 decompress is bounded to a fixed 4092-byte output buffer; any size mismatch is Error::Corruption.

Public for the fuzz harness (obj-fuzz/fuzz_targets/ page_decode_compressed.rs). Application code SHOULD reach for Pager::read_page instead.

§Errors

  • Error::Corruption with the supplied page_id if the v1 trailer’s 31-bit CRC does not match the recomputed CRC, if the compressed-length prefix is out of range, or if the LZ4 output is not exactly 4092 bytes.
  • Error::FormatFeatureUnsupported (when the compression Cargo feature is OFF and the trailer’s compression flag is set — unreachable on a well-formed open path, which refuses such files at Db::open).