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
impl ArchiveReader
Sourcepub fn open(path: &Path) -> Result<Self>
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).
Sourcepub fn read_file(&self, target: &str) -> Result<Vec<u8>>
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.
Sourcepub fn locate(&self, target: &str) -> Vec<ChunkLoc>
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.
Sourcepub fn files_meta(&self) -> Vec<ArtifactMeta>
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.
Sourcepub fn files_meta_with_prefix(&self, prefix: &str) -> Vec<ArtifactMeta>
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.