Struct ZipStreamReader
pub struct ZipStreamReader<R> { /* private fields */ }
Stream decoder for zip.
Implementations
impl<R> ZipStreamReader<R>
const fn new(reader: R) -> SelfCreate a new
ZipStreamReaderwith 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) -> SelfConfigure 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::extracttherefore extracts into a temporary directory inside the destination and moves the entries into place only if the check passes. AZipStreamVisitorpassed toZipStreamReader::visitsees every entry before the check, so it must not act on them untilvisitreturnsOk.
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