pub struct DocumentHeader {
pub collection_id: u32,
pub type_version: u32,
pub payload_len: u32,
pub payload_crc32c: u32,
}Expand description
In-memory representation of the per-document record header.
Constructed by DocumentHeader::read_from (on decode) or by
the codec on encode. All four fields are stored on disk as
little-endian u32.
Fields§
§collection_id: u32The catalog-assigned id of the collection this record belongs
to. Decode rejects mismatches with
Error::CollectionIdMismatch.
type_version: u32Document::VERSION of the type that wrote this record.
payload_len: u32Number of payload bytes that follow this header.
payload_crc32c: u32CRC32C of the payload bytes only — the page-trailer CRC32C on the containing leaf covers everything else.
Implementations§
Source§impl DocumentHeader
impl DocumentHeader
Sourcepub fn write_to(&self, dst: &mut Vec<u8>)
pub fn write_to(&self, dst: &mut Vec<u8>)
Write the header into dst. Appends exactly
DOC_HEADER_SIZE bytes.
Used by crate::codec::encode; the format is the
canonical disk shape so the buffer can be handed straight to
BTree::insert without further wrapping.
Sourcepub fn read_from(bytes: &[u8]) -> Result<Self>
pub fn read_from(bytes: &[u8]) -> Result<Self>
Decode a header from bytes. Validates only the layout
(length >= DOC_HEADER_SIZE); semantic checks (CRC,
collection-id, version range) are the caller’s responsibility.
§Errors
Returns Error::Corruption with page_id = 0 if bytes
is shorter than DOC_HEADER_SIZE.
Trait Implementations§
Source§impl Clone for DocumentHeader
impl Clone for DocumentHeader
Source§fn clone(&self) -> DocumentHeader
fn clone(&self) -> DocumentHeader
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DocumentHeader
impl Debug for DocumentHeader
Source§impl PartialEq for DocumentHeader
impl PartialEq for DocumentHeader
Source§fn eq(&self, other: &DocumentHeader) -> bool
fn eq(&self, other: &DocumentHeader) -> bool
self and other values to be equal, and is used by ==.