pub struct StreamingZip<F: Read + Seek> { /* private fields */ }Expand description
Streaming ZIP file reader
Implementations§
Source§impl<F: Read + Seek> StreamingZip<F>
impl<F: Read + Seek> StreamingZip<F>
Sourcepub fn new_with_limits(
file: F,
limits: Option<ZipLimits>,
) -> Result<Self, ZipError>
pub fn new_with_limits( file: F, limits: Option<ZipLimits>, ) -> Result<Self, ZipError>
Open a ZIP file with explicit runtime limits.
Sourcepub fn get_entry(&self, name: &str) -> Option<&CdEntry>
pub fn get_entry(&self, name: &str) -> Option<&CdEntry>
Get entry by filename (case-insensitive)
Sourcepub fn read_file(
&mut self,
entry: &CdEntry,
buf: &mut [u8],
) -> Result<usize, ZipError>
pub fn read_file( &mut self, entry: &CdEntry, buf: &mut [u8], ) -> Result<usize, ZipError>
Read and decompress a file into the provided buffer Returns number of bytes written to buffer
Sourcepub fn read_file_with_scratch(
&mut self,
entry: &CdEntry,
buf: &mut [u8],
input_buf: &mut [u8],
) -> Result<usize, ZipError>
pub fn read_file_with_scratch( &mut self, entry: &CdEntry, buf: &mut [u8], input_buf: &mut [u8], ) -> Result<usize, ZipError>
Read and decompress a file into the provided buffer using caller-provided scratch input.
This is intended for embedded callers that want deterministic allocation behavior.
input_buf must be non-empty.
Sourcepub fn read_file_to_writer<W: Write>(
&mut self,
entry: &CdEntry,
writer: &mut W,
) -> Result<usize, ZipError>
pub fn read_file_to_writer<W: Write>( &mut self, entry: &CdEntry, writer: &mut W, ) -> Result<usize, ZipError>
Stream a file’s decompressed bytes into an arbitrary writer.
For stored and DEFLATE entries this path is chunked and avoids full-entry output buffers.
Sourcepub fn read_file_to_writer_with_scratch<W: Write>(
&mut self,
entry: &CdEntry,
writer: &mut W,
input_buf: &mut [u8],
output_buf: &mut [u8],
) -> Result<usize, ZipError>
pub fn read_file_to_writer_with_scratch<W: Write>( &mut self, entry: &CdEntry, writer: &mut W, input_buf: &mut [u8], output_buf: &mut [u8], ) -> Result<usize, ZipError>
Stream a file’s decompressed bytes into an arbitrary writer using caller-provided scratch buffers.
This API is intended for embedded use cases where callers want strict control over
allocation and stack usage. input_buf and output_buf must both be non-empty.
For METHOD_STORED, only input_buf is used for chunked copying.
For METHOD_DEFLATED, both buffers are used.
Sourcepub fn read_file_at_offset(
&mut self,
local_header_offset: u64,
buf: &mut [u8],
) -> Result<usize, ZipError>
pub fn read_file_at_offset( &mut self, local_header_offset: u64, buf: &mut [u8], ) -> Result<usize, ZipError>
Read a file by its local header offset (avoids borrow issues) This is useful when you need to read a file after getting its metadata
Sourcepub fn validate_mimetype(&mut self) -> Result<(), ZipError>
pub fn validate_mimetype(&mut self) -> Result<(), ZipError>
Validate that the archive contains a valid EPUB mimetype file
Checks that a file named “mimetype” exists and its content is exactly
application/epub+zip, as required by the EPUB specification.
Sourcepub fn is_valid_epub(&mut self) -> bool
pub fn is_valid_epub(&mut self) -> bool
Check if this archive is a valid EPUB file
Convenience wrapper around validate_mimetype() that returns a boolean.
Sourcepub fn num_entries(&self) -> usize
pub fn num_entries(&self) -> usize
Get number of entries in central directory
Sourcepub fn get_entry_by_index(&self, index: usize) -> Option<&CdEntry>
pub fn get_entry_by_index(&self, index: usize) -> Option<&CdEntry>
Get entry by index