pub struct Archive { /* private fields */ }Expand description
An immutable ZIP input with a validated index and lazily verified members.
Opening validates namespace, counts, declared expansion, local headers, descriptors, and nonoverlapping member regions before decompressing files. Reading validates actual size and CRC before publishing/caching bytes. Repeated reads return the same immutable allocation. Nothing is extracted, executed, discovered as a case, or recursively opened as another archive.
The supported profile is single-volume ZIP32/ZIP64 with stored/deflated members, UTF-8 paths and no prepended executable. Ambiguous metadata end records, encryption, symlinks, special files and unsafe paths are refused.
Implementations§
Source§impl Archive
impl Archive
Sourcepub fn open(
bytes: impl AsRef<[u8]> + Into<Arc<[u8]>>,
limits: ArchiveLimits,
) -> Result<Self, Error>
pub fn open( bytes: impl AsRef<[u8]> + Into<Arc<[u8]>>, limits: ArchiveLimits, ) -> Result<Self, Error>
Index caller-owned bytes under explicit limits without filesystem I/O. An Arc input is retained without copying. Unread payload CRCs are not certified. Expansion limits apply to the sum of all declared members.
Sourcepub fn entries(&self) -> impl ExactSizeIterator<Item = &ArchiveEntry>
pub fn entries(&self) -> impl ExactSizeIterator<Item = &ArchiveEntry>
Members in deterministic path order, including explicit directories.
Sourcepub fn original_bytes(&self) -> Arc<[u8]> ⓘ
pub fn original_bytes(&self) -> Arc<[u8]> ⓘ
Exact original ZIP bytes, including its comment and compression data.
Sourcepub fn read(&mut self, path: &ArtifactPath) -> Result<Arc<[u8]>, Error>
pub fn read(&mut self, path: &ArtifactPath) -> Result<Arc<[u8]>, Error>
Read and CRC-verify a member, caching only a complete valid payload.
Sourcepub fn read_with_limit(
&mut self,
path: &ArtifactPath,
max_bytes: u64,
) -> Result<Arc<[u8]>, Error>
pub fn read_with_limit( &mut self, path: &ArtifactPath, max_bytes: u64, ) -> Result<Arc<[u8]>, Error>
Apply an additional per-read byte cap, including on cached members. A refusal does not populate the cache. Zero permits only empty members.
Sourcepub fn read_cancellable(
&mut self,
path: &ArtifactPath,
max_bytes: u64,
cancel: &Cancellation,
) -> Result<Arc<[u8]>, Error>
pub fn read_cancellable( &mut self, path: &ArtifactPath, max_bytes: u64, cancel: &Cancellation, ) -> Result<Arc<[u8]>, Error>
Read with cooperative cancellation between decompressor reads.