Skip to main content

StreamingZip

Struct StreamingZip 

Source
pub struct StreamingZip<F: Read + Seek> { /* private fields */ }
Expand description

Streaming ZIP file reader

Implementations§

Source§

impl<F: Read + Seek> StreamingZip<F>

Source

pub fn new(file: F) -> Result<Self, ZipError>

Open a ZIP file and parse the central directory

Source

pub fn new_with_limits( file: F, limits: Option<ZipLimits>, ) -> Result<Self, ZipError>

Open a ZIP file with explicit runtime limits.

Source

pub fn get_entry(&self, name: &str) -> Option<&CdEntry>

Get entry by filename (case-insensitive)

Source

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

Source

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.

Source

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.

Source

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.

Source

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

Source

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.

Source

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.

Source

pub fn num_entries(&self) -> usize

Get number of entries in central directory

Source

pub fn entries(&self) -> impl Iterator<Item = &CdEntry>

Iterate over all entries

Source

pub fn get_entry_by_index(&self, index: usize) -> Option<&CdEntry>

Get entry by index

Source

pub fn limits(&self) -> Option<ZipLimits>

Get the active limits used by this ZIP reader.

Auto Trait Implementations§

§

impl<F> Freeze for StreamingZip<F>
where F: Freeze,

§

impl<F> RefUnwindSafe for StreamingZip<F>
where F: RefUnwindSafe,

§

impl<F> Send for StreamingZip<F>
where F: Send,

§

impl<F> Sync for StreamingZip<F>
where F: Sync,

§

impl<F> Unpin for StreamingZip<F>
where F: Unpin,

§

impl<F> UnsafeUnpin for StreamingZip<F>
where F: UnsafeUnpin,

§

impl<F> UnwindSafe for StreamingZip<F>
where F: UnwindSafe,

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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.