tinyzip 0.1.0

Tiny no_std no_alloc low-level ZIP navigation
Documentation
  • Coverage
  • 100%
    54 out of 54 items documented1 out of 29 items with examples
  • Size
  • Source code size: 2.75 MB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 4.44 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 18s Average build duration of successful builds.
  • all releases: 15s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • lovasoa/tinyzip
    1 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • lovasoa

tinyzip

tinyzip is a tiny no_std, no_alloc ZIP navigation crate.

It does not decompress data. It only finds the central directory, iterates entries, and exposes raw byte ranges so callers can read names, comments, extra fields, local headers, and the stored or compressed payload bytes themselves.

Supported

  • Single-disk ZIP archives
  • Leading prefix data and trailing junk
  • EOCD and ZIP64 EOCD/locator
  • Central-directory iteration without buffering the directory
  • Lazy reading of variable-length metadata and local headers

Not Supported

  • Multi-disk ZIP archives
  • Decompression
  • Filename decoding / path normalization
  • Central-directory encryption or compressed central-directory structures

Core API

use tinyzip::{Archive, Reader};

fn inspect<R: Reader>(reader: R) -> Result<(), tinyzip::Error<R::Error>> {
    let archive = Archive::open(reader)?;
    for entry in archive.entries() {
        let entry = entry?;
        let mut name = [0u8; 64];
        let path = entry.read_path(&mut name)?;
        let path_text = if entry.path_is_utf8() {
            Some(core::str::from_utf8(path).expect("path_is_utf8 comes from the ZIP UTF-8 flag"))
        } else {
            None
        };
        let data = entry.data_range()?;
        let _ = (path, path_text, data);
    }
    Ok(())
}

The API stays low-level on purpose:

  • Reader is a tiny random-access trait that can be implemented directly on top of immutable positioned reads.
  • With the std feature, tinyzip::std_io::ReadSeekReader adapts Read + Seek and tinyzip::std_io::UnixFileReader adapts Unix FileExt.
  • Archive stores only fixed-size archive metadata.
  • Entry borrows the archive and holds one parsed central-directory record.
  • ZIP paths are exposed as raw bytes; they may be nested /-separated paths, bare file names, or directory markers ending in /.
  • Entry::path_is_utf8() exposes whether the ZIP metadata marks the path as UTF-8.
  • Variable-length fields are read into caller-provided buffers.
  • Data location is resolved lazily from the local header only when needed.