pub struct UrnaView<'a> {
pub header: UrnaHeader,
pub section_table: Vec<SectionEntry>,
pub manifest: Manifest,
pub footer: UrnaFooter,
/* private fields */
}Fields§
§header: UrnaHeader§section_table: Vec<SectionEntry>§manifest: ManifestImplementations§
Source§impl<'a> UrnaView<'a>
impl<'a> UrnaView<'a>
Sourcepub fn decoded_section(&self, section_id: u32) -> Result<Cow<'a, [u8]>>
pub fn decoded_section(&self, section_id: u32) -> Result<Cow<'a, [u8]>>
Logical (decoded) bytes of a section’s payload. Borrows for raw
encoding; copies for zstd. Float16/int8 embedding payloads are
returned as-is - the runtime dispatches on manifest.dtype.
The chunks_canonical (0x02) section gets two extra, content_hash-
invariant rewrites here so its decoded bytes are byte-identical to a
plain build: a dict-framed (zstd_dict, id 5) payload is decoded
against the shared dictionary in section 0x0A, and a deduped pool is
re-expanded through the back-reference array in section 0x0B. Both
optional sections are excluded from content_hash, so they never move a
citation; the re-expansion happens BEFORE content_hash sees the bytes.
Sourcepub fn search_contract(&self) -> Result<SearchContract>
pub fn search_contract(&self) -> Result<SearchContract>
Decode the search_contract section. Already validated to agree
with the manifest at construction time.
Sourcepub fn file_hash_hex(&self) -> String
pub fn file_hash_hex(&self) -> String
sha256:<hex> of the file as written, including the footer.
Sourcepub fn content_hash_hex(&self) -> Result<String>
pub fn content_hash_hex(&self) -> Result<String>
sha256:<hex> of the canonical sections in the order fixed by spec
(see CANONICAL_SECTIONS). Hashes the decoded bytes so two
files that wire-compress the same logical content (zstd vs raw)
produce the same content_hash and therefore stable citations.
Quantized embeddings (float16 / int8) hash their on-disk bytes -
they’re already the canonical representation for that precision.
Optional sections (HNSW, BM25, and every reserved 0x09+ section) are
NOT included, and neither is the manifest: the manifest is covered by
file_hash only. So additive manifest fields (a new Option field, a
capabilities_ext flag) move file_hash but NEVER content_hash, which
is why adding a capability cannot invalidate a urna:// citation.
Source§impl UrnaView<'_>
impl UrnaView<'_>
Sourcepub fn validate_embeddings_values(&self) -> Result<()>
pub fn validate_embeddings_values(&self) -> Result<()>
Walk the embeddings section and reject any NaN/Inf value. Works for all supported dtypes.
Source§impl<'a> UrnaView<'a>
impl<'a> UrnaView<'a>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn raw_bytes(&self) -> &[u8] ⓘ
Sourcepub fn entry(&self, section_id: u32) -> Result<&SectionEntry>
pub fn entry(&self, section_id: u32) -> Result<&SectionEntry>
Look up the section table entry for section_id.
Sourcepub fn get_section_data(&self, section_id: u32) -> Result<&'a [u8]>
pub fn get_section_data(&self, section_id: u32) -> Result<&'a [u8]>
Physical (on-disk, mmap-backed) bytes of a section’s payload.
Use decoded_section if you want the logical bytes (e.g. zstd
decompressed) the chunk decoders consume.