Struct ZipStreamReader

pub struct ZipStreamReader<R> { /* private fields */ }

Stream decoder for zip.

Implementations

impl<R> ZipStreamReader<R>

const fn new(reader: R) -> Self

Create a new ZipStreamReader with default settings. For backward-compatibility, this doesn't check that the local headers match the central directory.

const fn enforce_header_consistency(self, enforce: bool) -> Self

Configure whether to validate consistency between Local File Headers (LFH) and Central Directory File Headers (CDFH).

When enabled, any discrepancy (such as Zip Cloaking / Dual-Header Smuggling attacks where an attacker provides different names or hidden files across headers) will cause the extraction to abort with ZipError::InvalidArchive.

The headers can only be compared once the central directory, at the end of the stream, has been read. ZipStreamReader::extract therefore extracts into a temporary directory inside the destination and moves the entries into place only if the check passes. A ZipStreamVisitor passed to ZipStreamReader::visit sees every entry before the check, so it must not act on them until visit returns Ok.

impl<R: Read> ZipStreamReader<R>

fn visit<V: ZipStreamVisitor>(self, visitor: &mut V) -> ZipResult<()>

Iterate over the stream and extract all file and their metadata.

fn extract<P: AsRef<Path>>(self, directory: P) -> ZipResult<()>

Extract a Zip archive into a directory, overwriting files if they already exist. Paths are sanitized with ZipFile::enclosed_name.

Extraction is not atomic; If an error is encountered, some of the files may be left on disk. The file(s) and dir(s) are first created, then the permissions are applied to them

Extraction of symlink is not possible since we don't have access to the external attributes in the local headers of the entries

Trait Implementations

impl<R: Debug> Debug for ZipStreamReader<R>

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Auto Trait Implementations

impl<R> Freeze for ZipStreamReader<R> where R: Freeze,

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

impl<R> Send for ZipStreamReader<R> where R: Send,

impl<R> Sync for ZipStreamReader<R> where R: Sync,

impl<R> Unpin for ZipStreamReader<R> where R: Unpin,

impl<R> UnsafeUnpin for ZipStreamReader<R> where R: UnsafeUnpin,

impl<R> UnwindSafe for ZipStreamReader<R> where R: UnwindSafe,

Blanket Implementations

impl<T> Any for ZipStreamReader<R> where T: 'static + ?Sized,

impl<T> Borrow<T> for ZipStreamReader<R> where T: ?Sized,

impl<T> BorrowMut<T> for ZipStreamReader<R> where T: ?Sized,

impl<T> From<T> for ZipStreamReader<R>

impl<T> Same for ZipStreamReader<R>

impl<T, U> Into<U> for ZipStreamReader<R> where U: From<T>,

impl<T, U> TryFrom<U> for ZipStreamReader<R> where U: Into<T>,

impl<T, U> TryInto<U> for ZipStreamReader<R> where U: TryFrom<T>,