Skip to main content

ArchiveReader

Struct ArchiveReader 

Source
pub struct ArchiveReader { /* private fields */ }
Expand description

A cached, open-once random-access reader over a sealed v0.7 archive.

The free functions locate_file and get_files_meta_with_prefix re-open the file and re-read the footer + manifest + both reserved sections (the lookup sub-index and the trie) on every call, and re-decode_lookup every row each time — three manifest reads per lookup (analysis §1.5). For a long-lived reader (a browsing UI, holger’s dynamic side, selective restore) that is pure repeated I/O.

ArchiveReader::open reads the footer, manifest, lookup sub-index and trie once, decodes the lookup columns once, and builds the fst map once. Every subsequent locate, files_meta and files_meta_with_prefix query is then served from memory — an fst get (O(key)) or a binary search (O(log n)) over the already-decoded columns — with zero further I/O and zero per-call manifest reads. The on-disk format is untouched; results are identical to the equivalent free function.

Implementations§

Source§

impl ArchiveReader

Source

pub fn open(path: &Path) -> Result<Self>

Open a sealed v0.7 archive and cache its manifest + lookup + trie. Reads the manifest exactly once (vs three re-reads per free-function call).

Source

pub fn row_count(&self) -> usize

Total number of chunk rows cached (across all files).

Source

pub fn read_file(&self, target: &str) -> Result<Vec<u8>>

Read a single file’s bytes by relative path — the cached, held-open equivalent of get_file. Uses the in-memory locate (no manifest re-read, no per-call decode_lookup) and the archive handle opened once in open, then preads + decompresses + blake3-verifies each chunk. This is the selective-restore entry point: hold one reader and call read_file per artifact instead of paying a full index re-parse on every get_file.

Returns an error if target is not present in the archive.

Source

pub fn locate(&self, target: &str) -> Vec<ChunkLoc>

Locate every chunk of target, sorted by chunk_seq — the cached equivalent of locate_file, but with no I/O after open.

Source

pub fn files_meta(&self) -> Vec<ArtifactMeta>

Per-file metadata for every file, sorted by relative_path — the cached equivalent of get_all_files_meta.

Source

pub fn files_meta_with_prefix(&self, prefix: &str) -> Vec<ArtifactMeta>

Per-file metadata for files whose path starts with prefix — the cached equivalent of get_files_meta_with_prefix.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.