pub struct ZipArchive<R> { /* private fields */ }Expand description
An indexed ZIP archive over an immutable, seekable source.
If a decoding operation returns an error or is cancelled while in progress,
subsequent decoding operations return DecodeError::Poisoned. This applies
to member iteration and selection, payload consumption, metadata validation,
and Self::reader_mut.
Implementations§
Source§impl<R: AsyncRead + AsyncSeek + Unpin> ZipArchive<R>
impl<R: AsyncRead + AsyncSeek + Unpin> ZipArchive<R>
Sourcepub async fn open(reader: R) -> Result<Self, DecodeError>
pub async fn open(reader: R) -> Result<Self, DecodeError>
Opens the archive with the default DecodePolicy.
Sourcepub async fn open_with_policy(
reader: R,
policy: DecodePolicy,
) -> Result<Self, DecodeError>
pub async fn open_with_policy( reader: R, policy: DecodePolicy, ) -> Result<Self, DecodeError>
Opens the archive and validates its central directory under the supplied DecodePolicy.
Local headers are checked on member access or by Self::validate_all.
Sourcepub fn entries(&self) -> &[IndexedEntry]
pub fn entries(&self) -> &[IndexedEntry]
Returns indexed members without fetching local records or payloads.
Sourcepub fn resolved(&self, index: usize) -> Option<Entry<'_>>
pub fn resolved(&self, index: usize) -> Option<Entry<'_>>
Returns a previously checked entry by index, without performing I/O.
Returns None if the index is out of bounds or the member is unresolved.
Sourcepub async fn member(
&mut self,
index: usize,
) -> Result<Option<Member<ZipMemberPayload<'_, R>>>, DecodeError>
pub async fn member( &mut self, index: usize, ) -> Result<Option<Member<ZipMemberPayload<'_, R>>>, DecodeError>
Selects a member by central-directory index.
The local header and data descriptor are checked against the directory before a member is returned. Timestamps and Windows NT security descriptors are neither compared nor exposed. Successful metadata checks are cached. An unfinished prior payload is drained and validated first. The next sequential read resumes immediately after the selected entry. Repeated explicit selections repeat the associated I/O and decompression work. Errors and cancellation poison the archive; subsequent operations fail.
Sourcepub async fn validate_all(&mut self) -> Result<(), DecodeError>
pub async fn validate_all(&mut self) -> Result<(), DecodeError>
Checks metadata for all members, including those never selected.
An active payload is drained first. Other payloads are not decoded; their CRCs and decoded sizes are still checked when they are read.
Sourcepub async fn reader_mut(&mut self) -> Result<&mut R, DecodeError>
pub async fn reader_mut(&mut self) -> Result<&mut R, DecodeError>
Borrows the source for operations such as HTTP range prefetching.
Drains and validates an active payload before lending the reader. The caller may change its cursor, but must not replace the source or change its contents. Subsequent member selection seeks to the checked offset.
Sourcepub fn into_inner(self) -> R
pub fn into_inner(self) -> R
Returns the source without validating any remaining payloads.
Trait Implementations§
Source§impl<R: AsyncRead + AsyncSeek + Unpin> Archive for ZipArchive<R>
impl<R: AsyncRead + AsyncSeek + Unpin> Archive for ZipArchive<R>
Source§type Error = DecodeError
type Error = DecodeError
Source§type Payload<'a> = ZipMemberPayload<'a, R>where
Self: 'a,
type Payload<'a> = ZipMemberPayload<'a, R>where
Self: 'a,
Source§async fn next_member(
&mut self,
) -> Result<Option<Member<Self::Payload<'_>>>, Self::Error>
async fn next_member( &mut self, ) -> Result<Option<Member<Self::Payload<'_>>>, Self::Error>
Members::next. Read more