Skip to main content

ZipArchive

Struct ZipArchive 

Source
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>

Source

pub async fn open(reader: R) -> Result<Self, DecodeError>

Opens the archive with the default DecodePolicy.

Source

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.

Source

pub fn entries(&self) -> &[IndexedEntry]

Returns indexed members without fetching local records or payloads.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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>

Source§

type Error = DecodeError

The archive-format error returned during member iteration.
Source§

type Payload<'a> = ZipMemberPayload<'a, R>
where Self: 'a,

The streaming payload type lent by each file member.
Source§

async fn next_member( &mut self, ) -> Result<Option<Member<Self::Payload<'_>>>, Self::Error>

Reads the next format-neutral member for Members::next. Read more
Source§

fn members(self) -> Members<Self>

Consumes this archive and returns its lending member cursor. Read more
Source§

async fn extract_in<P>( self, destination: P, policy: ExtractPolicy, ) -> Result<(), ExtractError<Self::Error>>
where P: AsRef<Path>,

Securely extracts this archive beneath destination under policy. Read more

Auto Trait Implementations§

§

impl<R> !UnwindSafe for ZipArchive<R>

§

impl<R> Forget for ZipArchive<R>

§

impl<R> Freeze for ZipArchive<R>
where R: Freeze, *const u8 is !null: Freeze, PhantomData<IndexedEntry>: Freeze, PhantomData<Option<ResolvedMember>>: Freeze, PhantomData<u8>: Freeze, *const DeflateState is !null: Freeze, PhantomData<DeflateState>: Freeze,

§

impl<R> Move for ZipArchive<R>

§

impl<R> RefUnwindSafe for ZipArchive<R>
where R: RefUnwindSafe,

§

impl<R> Send for ZipArchive<R>
where R: Send, RawVecInner: Send, BoxRaw<str>: Send, BoxRaw<[u8]>: Send, BoxRaw<DeflateState>: Send,

§

impl<R> Sync for ZipArchive<R>
where R: Sync, RawVecInner: Sync, BoxRaw<str>: Sync, BoxRaw<[u8]>: Sync, BoxRaw<DeflateState>: Sync,

§

impl<R> Unpin for ZipArchive<R>
where R: Unpin, *const u8 is !null: Unpin, Box<str>: Unpin, Box<[u8]>: Unpin, Box<DeflateState>: Unpin,

§

impl<R> UnsafeUnpin for ZipArchive<R>

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