pub struct FileHeader {
pub format_version: u16,
pub manifest_offset: u64,
pub cas_offset: u64,
}Expand description
The 24-byte header at the start of a baked monolithic .pvdb file.
| Offset | Size | Field |
|---|---|---|
| 0 | 4 | MAGIC_BYTES |
| 4 | 2 | format_version |
| 6 | 2 | flags (reserved) |
| 8 | 8 | manifest_offset |
| 16 | 8 | cas_offset |
Fields§
§format_version: u16On-disk format version of this file (see FORMAT_VERSION).
manifest_offset: u64Absolute byte offset of the manifest (catalog) block.
cas_offset: u64Absolute byte offset of the CAS blob pool.
Implementations§
Source§impl FileHeader
impl FileHeader
Sourcepub const ENCODED_LEN: usize = FILE_HEADER_SIZE
pub const ENCODED_LEN: usize = FILE_HEADER_SIZE
Serialized length, in bytes.
Sourcepub const fn new(manifest_offset: u64, cas_offset: u64) -> Self
pub const fn new(manifest_offset: u64, cas_offset: u64) -> Self
Construct a header from its two offsets, stamped with the current
FORMAT_VERSION.
Sourcepub const fn new_versioned(
manifest_offset: u64,
cas_offset: u64,
format_version: u16,
) -> Self
pub const fn new_versioned( manifest_offset: u64, cas_offset: u64, format_version: u16, ) -> Self
Construct a header stamped with an explicit format_version, so a baker
can write the lowest version a file actually needs (see
FORMAT_VERSION_BASE).
Sourcepub fn encode(&self) -> [u8; 24]
pub fn encode(&self) -> [u8; 24]
Encode to the fixed 24-byte little-endian wire form, including the magic bytes and format version. The two flag bytes are reserved and written as zero.
Sourcepub fn decode(buf: &[u8]) -> Result<Self>
pub fn decode(buf: &[u8]) -> Result<Self>
Decode and validate the magic signature and format version.
Returns PvError::SignatureMismatch if the leading bytes are not
MAGIC_BYTES, or PvError::Corruption if the file’s format version
is zero or newer than this build can read (FORMAT_VERSION). Rejecting
an unknown version is what stops a future on-disk change from being
silently mis-parsed by an older reader.