Skip to main content

Header

Struct Header 

Source
pub struct Header {
Show 26 fields pub version: u8, pub flags: u8, pub metadata_offset: u64, pub metadata_len: u64, pub dictionary_offset: u64, pub dictionary_len: u64, pub root_dir_offset: u64, pub root_dir_len: u64, pub pyramid_meta_offset: u64, pub pyramid_meta_len: u64, pub dict_codec: u8, pub block_codec: u8, pub pyramid_levels: u16, pub quad_count: u64, pub term_count: u64, pub content_hash: [u8; 16], pub named_graphs_offset: u64, pub named_graphs_len: u64, pub schema_meta_len: u32, pub text_index_offset: u64, pub text_index_len: u64, pub text_index_partial: bool, pub build_info_offset: u64, pub build_info_len: u64, pub perms: PermSet, pub extra_sections: Vec<Section>,
}
Expand description

Decoded file header. All multi-byte fields are little-endian on disk. The *_offset / *_len fields are a convenience view over the section directory (populated from it on parse, emitted back to it on serialize).

Fields§

§version: u8

Format version of the parsed file (currently MIN_STABLE_READ_VERSION through CURRENT_FORMAT_VERSION).

§flags: u8§metadata_offset: u64§metadata_len: u64§dictionary_offset: u64§dictionary_len: u64§root_dir_offset: u64§root_dir_len: u64§pyramid_meta_offset: u64§pyramid_meta_len: u64§dict_codec: u8§block_codec: u8§pyramid_levels: u16§quad_count: u64§term_count: u64§content_hash: [u8; 16]

First 16 bytes of the blake3 content hash — an immutable validator.

§named_graphs_offset: u64

Named-graphs section (0 if the file has only the default graph).

§named_graphs_len: u64§schema_meta_len: u32

Byte length of the trailing schema-pyramid block within the pyramid-meta section (0 if none). A reader fetches only that block — at pyramid_meta_offset + pyramid_meta_len - schema_meta_len — for an index/dictionary/summary-free Tier-0 coherence check.

§text_index_offset: u64

Full-text index section (0 if the file has none; built with rete build --text-index). See SectionKind::TextIndex.

§text_index_len: u64§text_index_partial: bool

The full-text index covers only some predicates: it is written (and was read) as SectionKind::TextIndexPartial rather than SectionKind::TextIndex. false for every file without one.

§build_info_offset: u64

Build-conditions section (0 if absent). See SectionKind::BuildInfo: an opaque per-build record that is not covered by the content hash.

§build_info_len: u64§perms: PermSet

Which index permutations the file’s index containers carry (crate::index::PermSet).

On disk this is one byte at [50], inside the reserved core span, and 0 means all six — so every file written before the mask existed decodes as PermSet::ALL and a full six-permutation build stays byte-identical to what it always was. A lean file writes its mask (0b000_0111 for SPO+POS+OSP), and its index container then holds three sections rather than six, which is what an older reader trips over.

§extra_sections: Vec<Section>

Directory entries of the kinds added after the generation-1 freeze — SectionKind::LabelIndex (8), SectionKind::Schema (9) — and of any kind this build doesn’t recognize, preserved verbatim in directory order. None of them is covered by the header content hash.

Implementations§

Source§

impl Header

Source

pub fn to_bytes(&self) -> [u8; 1024]

Serialize into a fixed 1024-byte array.

Source

pub fn from_bytes(b: &[u8]) -> Result<Header, HeaderError>

Parse a header from the first 1024 bytes of a file.

Source

pub fn label_index_section(&self) -> Option<Section>

The LABEL_INDEX section (kind 8), if the file carries a non-empty one.

Source

pub fn schema_section(&self) -> Option<Section>

The SCHEMA section (kind 9), if the file carries a non-empty one.

Source

pub fn has_quads(&self) -> bool

Source

pub fn expected_file_len(&self) -> Option<u64>

The total file length implied by this header alone: the writer lays the sections out back-to-back after the 1 KiB header and ends the file with the 4-byte RETE footer, so the furthest offset + length in the section directory plus 4 is the file length.

This is the one length signal a remote reader can always trust: an HTTP host may advertise the size of a compressed representation in Content-Length (GitHub Pages gzips — a 71 MB file HEADs as 58 MB) while serving ranges over the identity bytes, and may hide Content-Range from cross-origin JS by omitting Access-Control-Expose-Headers. The header travels in band — in the first 1 KiB range read — so it cannot be skewed by transport encoding.

None if any directory entry overflows u64 (a crafted or corrupt header must yield “unknown”, never a panic or a wrapped length — the weekly fuzz caught verify() on exactly this class of input).

Source

pub fn has_quoted_triples(&self) -> bool

Does the file contain RDF-star quoted triples ([FLAG_HAS_QUOTED_TRIPLES])?

Source

pub fn has_tile_synopsis(&self) -> bool

Do the tiled index sections carry a [FLAG_TILE_SYNOPSIS] trailer?

Source

pub fn text_index_covers_named_graphs(&self) -> bool

Does the full-text index cover the named graphs’ literals too ([FLAG_TEXT_INDEX_NAMED_GRAPHS])? Known from the header alone.

Source

pub fn text_index_payload(&self) -> (u64, u64)

The (offset, length) of the text index’s payload — the token-table varint, the token table and the postings. That is the whole section for kind 6; a kind-11 section starts with its 16-byte self-digest, which this skips. (offset, 0) past a kind-11 section too short for its digest.

Source

pub fn section(&self, kind: SectionKind) -> Option<Section>

The directory entry for a section kind, or None if absent. Known kinds read from the named convenience fields; unknown kinds from extra_sections.

Source

pub fn with_section(self, kind: SectionKind, offset: u64, length: u64) -> Header

Attach (or overwrite) a section’s (offset, length) — the extension point for new top-level sections. Known kinds set the named fields; an unknown kind is appended to extra_sections.

Source

pub fn has_quad_index(&self) -> bool

Are the named graphs stored in the quad index ([FLAG_QUAD_INDEX])?

Source

pub fn quad_index_section(&self) -> Option<Section>

The QUAD_INDEX section, when the directory lists a non-empty one.

Source

pub fn index_container_sections(&self) -> usize

How many sections the index container (kind 3) holds: one per stored permutation, plus the quad-index seal when [FLAG_QUAD_INDEX] is set.

Trait Implementations§

Source§

impl Clone for Header

Source§

fn clone(&self) -> Header

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Header

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for Header

Source§

impl PartialEq for Header

Source§

fn eq(&self, other: &Header) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Header

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V