pub struct StreamingZipReader { /* private fields */ }Expand description
Streaming ZIP archive reader with adaptive buffering
Implementations§
Source§impl StreamingZipReader
impl StreamingZipReader
Sourcepub fn open<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn open<P: AsRef<Path>>(path: P) -> Result<Self>
Open a ZIP file and read its central directory with default buffer size
Sourcepub fn open_with_buffer_size<P: AsRef<Path>>(
path: P,
buffer_size: Option<usize>,
) -> Result<Self>
pub fn open_with_buffer_size<P: AsRef<Path>>( path: P, buffer_size: Option<usize>, ) -> Result<Self>
Open a ZIP file with custom buffer size for optimized reading
Providing a buffer size hint can improve read performance:
- Small ZIPs (<10MB): 32KB buffer
- Medium ZIPs (<100MB): 128KB buffer
- Large ZIPs (≥100MB): 512KB buffer (default)
§Example
// Optimize for large ZIP files
let reader = StreamingZipReader::open_with_buffer_size(
"large_archive.zip",
Some(1024 * 1024) // 1MB buffer for very large files
)?;Sourcepub fn find_entry(&self, name: &str) -> Option<&ZipEntry>
pub fn find_entry(&self, name: &str) -> Option<&ZipEntry>
Find an entry by name
Sourcepub fn read_entry(&mut self, entry: &ZipEntry) -> Result<Vec<u8>>
pub fn read_entry(&mut self, entry: &ZipEntry) -> Result<Vec<u8>>
Read an entry’s decompressed data into a vector
Sourcepub fn read_entry_streaming_by_name(
&mut self,
name: &str,
) -> Result<Box<dyn Read + '_>>
pub fn read_entry_streaming_by_name( &mut self, name: &str, ) -> Result<Box<dyn Read + '_>>
Get a streaming reader for an entry by name (for large files) Returns a reader that decompresses data on-the-fly without loading everything into memory
Sourcepub fn read_entry_streaming(
&mut self,
entry: &ZipEntry,
) -> Result<Box<dyn Read + '_>>
pub fn read_entry_streaming( &mut self, entry: &ZipEntry, ) -> Result<Box<dyn Read + '_>>
Get a streaming reader for an entry (for large files).
Returns a Read impl that decompresses (and, if encrypted, decrypts)
data on-the-fly without loading the entire entry into memory.
§Encrypted entries
When the encryption feature is enabled and the entry is encrypted,
this method returns a streaming reader that decrypts on-the-fly.
Callers must read all bytes and then call finish() on the returned
reader to verify the HMAC-SHA1 authentication tag. Because the
decompressor sits above the decryptor in the pipeline, the HMAC is
computed over the compressed ciphertext bytes rather than the
decompressed plaintext — this is a known limitation of the streaming
path. For full WinZip AE-2 compliance (HMAC over plaintext) use
read_entry() instead.
§Errors
Returns SZipError::EncryptionError if the entry is encrypted but
set_password() was not called or the password is wrong.