Crate eazip

Crate eazip 

Source
Expand description

An simple yet flexible zip library.

This crate provides tools to read and write ZIP archives. It aims at being nice to use for developpers, which includes a good and flexible API, readable source code and clean maintenance.

Given how loose the ZIP spec is about what is a valid ZIP file and the history of security issues around them, this crate also aims at being robust and secure against malicious input. It might therefore may reject some “technically valid” ZIP files. If your ZIP file does not validate but you think it should, feel free to file an issue.

See Archive for reading archives and ArchiveWriter for creating ones.

§Cargo features

  • std: mandatory feature for forward-compatibility.
  • deflate: enable deflate compression and decompression.
  • zstd: enable zstd compression and decompression.
  • parallel: enable parallel ZIP file extraction.

§Example

use std::io;

// Open a ZIP archive from a file path
let mut archive = eazip::Archive::open("example.zip")?;

// Print some metadata for every entry in the archive
for entry in archive.entries() {
    println!("File \"{}\" of type {:?} and compressed size {}", entry.name(), entry.file_type, entry.compressed_size);
}

// Print the content of the file "hello.txt"
let mut hello = archive.get_by_name("hello.txt").ok_or(io::ErrorKind::NotFound)?;
let content = io::read_to_string(hello.read()?)?;

println!("Content of hello.txt: {content}");

Re-exports§

pub use read::Archive;
pub use write::ArchiveWriter;

Modules§

read
Utilities to read an archive.
write
Utilities to write an archive.

Structs§

CompressionMethod
A compression method used in an archive.
Compressor
An adapter to compress a stream.
Decompressor
An adapter to decompress a stream.
Timestamp
A timestamp for an entry in an archive.

Enums§

FileType
The type of an entry in an archive.