Skip to main content

UrnaView

Struct UrnaView 

Source
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: Manifest§footer: UrnaFooter

Implementations§

Source§

impl<'a> UrnaView<'a>

Source

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.

Source

pub fn search_contract(&self) -> Result<SearchContract>

Decode the search_contract section. Already validated to agree with the manifest at construction time.

Source

pub fn file_hash_hex(&self) -> String

sha256:<hex> of the file as written, including the footer.

Source

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<'a> UrnaView<'a>

Source

pub fn from_bytes(data: &'a [u8]) -> Result<Self>

Source§

impl UrnaView<'_>

Source

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>

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn raw_bytes(&self) -> &[u8] ⓘ

Source

pub fn entry(&self, section_id: u32) -> Result<&SectionEntry>

Look up the section table entry for section_id.

Source

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.

Auto Trait Implementations§

§

impl<'a> Freeze for UrnaView<'a>

§

impl<'a> RefUnwindSafe for UrnaView<'a>

§

impl<'a> Send for UrnaView<'a>

§

impl<'a> Sync for UrnaView<'a>

§

impl<'a> Unpin for UrnaView<'a>

§

impl<'a> UnsafeUnpin for UrnaView<'a>

§

impl<'a> UnwindSafe for UrnaView<'a>

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> 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, 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.