eazip/
lib.rs

1//! An simple yet flexible zip library.
2//!
3//! This crate provides tools to read and write ZIP archives. It aims at being
4//! nice to use for developpers, which includes a good and flexible API,
5//! readable source code and clean maintenance.
6//!
7//! Given how loose the ZIP spec is about what is a valid ZIP file and the
8//! history of security issues around them, this crate also aims at being robust
9//! and secure against malicious input. It might therefore may reject some
10//! "technically valid" ZIP files. If your ZIP file does not validate but you
11//! think it should, feel free to file an issue.
12//!
13//! See [`Archive`] for reading archives and [`ArchiveWriter`] for creating ones.
14//!
15//! # Cargo features
16//!
17//! - `std`: mandatory feature for forward-compatibility.
18//! - `deflate`: enable deflate compression and decompression.
19//! - `zstd`: enable zstd compression and decompression.
20//! - `parallel`: enable parallel ZIP file extraction.
21//!
22//! # Example
23//!
24//! ```no_run
25//! use std::io;
26//!
27//! // Open a ZIP archive from a file path
28//! let mut archive = eazip::Archive::open("example.zip")?;
29//!
30//! // Print some metadata for every entry in the archive
31//! for entry in archive.entries() {
32//!     println!("File \"{}\" of type {:?} and compressed size {}", entry.name(), entry.file_type, entry.compressed_size);
33//! }
34//!
35//! // Print the content of the file "hello.txt"
36//! let mut hello = archive.get_by_name("hello.txt").ok_or(io::ErrorKind::NotFound)?;
37//! let content = io::read_to_string(hello.read()?)?;
38//!
39//! println!("Content of hello.txt: {content}");
40//! # Ok::<(), io::Error>(())
41//! ```
42
43#![cfg_attr(docsrs, feature(doc_cfg))]
44
45#[cfg(not(feature = "std"))]
46compile_error!("`no_std` is not supported yet");
47
48mod compression;
49pub mod read;
50mod types;
51mod utils;
52pub mod write;
53
54pub use compression::{CompressionMethod, Compressor, Decompressor};
55pub use read::Archive;
56pub use utils::{FileType, Timestamp};
57pub use write::ArchiveWriter;