Skip to main content

decode_header

Function decode_header 

Source
pub fn decode_header(page: &Page) -> Result<FileHeader>
Expand description

Decode the page-0 header from the given page buffer. Validates magic, page-size, major version, the per-major format_minor constraint, and the header_crc32c field.

Phase 8 (issue #17): readers accept any SUPPORTED_FORMAT_MAJORS value (0 for pre-1.0 databases, 1 for v1.0+). The per-major format_minor constraint is:

  • format_major = 0format_minor ∈ {0, 1, 2} (the pre-1.0 incremental rollout: baseline, compression-capable, encryption-capable).
  • format_major = 1format_minor = 2 (the v1.0 frozen feature-complete value; the only valid minor inside the v1.x series).

§Errors

  • Error::InvalidFormat if the magic bytes do not match, if format_major is unsupported by this build, if format_minor is not valid for the file’s format_major, or if page_size disagrees with PAGE_SIZE.
  • Error::Corruption with page_id = 0 if the stored header_crc32c does not match the CRC32C of the rest of the page.