s_zip/
lib.rs

1//! # s-zip: High-Performance Streaming ZIP Library
2//!
3//! `s-zip` is a lightweight, high-performance ZIP library focused on streaming operations
4//! with minimal memory footprint. Perfect for working with large ZIP files without loading
5//! everything into memory.
6//!
7//! ## Features
8//!
9//! - **Streaming Read**: Read ZIP entries on-the-fly without loading entire archive
10//! - **Streaming Write**: Write ZIP files with on-the-fly compression, no temp files
11//! - **Low Memory**: Constant memory usage regardless of ZIP file size
12//! - **Fast**: Optimized for performance with minimal allocations
13//! - **Simple API**: Easy to use, intuitive interface
14//!
15//! ## Quick Start
16//!
17//! ### Reading a ZIP file
18//!
19//! ```no_run
20//! use s_zip::StreamingZipReader;
21//!
22//! let mut reader = StreamingZipReader::open("archive.zip")?;
23//!
24//! // List all entries
25//! for entry in reader.entries() {
26//!     println!("{}: {} bytes", entry.name, entry.uncompressed_size);
27//! }
28//!
29//! // Read a specific file
30//! let data = reader.read_entry_by_name("file.txt")?;
31//! # Ok::<(), s_zip::SZipError>(())
32//! ```
33//!
34//! ### Writing a ZIP file
35//!
36//! ```no_run
37//! use s_zip::StreamingZipWriter;
38//!
39//! let mut writer = StreamingZipWriter::new("output.zip")?;
40//!
41//! writer.start_entry("file1.txt")?;
42//! writer.write_data(b"Hello, World!")?;
43//!
44//! writer.start_entry("file2.txt")?;
45//! writer.write_data(b"Another file")?;
46//!
47//! writer.finish()?;
48//! # Ok::<(), s_zip::SZipError>(())
49//! ```
50//!
51//! ### Using arbitrary writers (in-memory, network, etc.)
52//!
53//! ```no_run
54//! use s_zip::StreamingZipWriter;
55//! use std::io::Cursor;
56//!
57//! // Write ZIP to in-memory buffer
58//! let buffer = Vec::new();
59//! let cursor = Cursor::new(buffer);
60//! let mut writer = StreamingZipWriter::from_writer(cursor)?;
61//!
62//! writer.start_entry("data.txt")?;
63//! writer.write_data(b"In-memory ZIP content")?;
64//!
65//! // finish() returns the writer, allowing you to extract the data
66//! let cursor = writer.finish()?;
67//! let zip_bytes = cursor.into_inner();
68//!
69//! println!("Created ZIP with {} bytes", zip_bytes.len());
70//! # Ok::<(), s_zip::SZipError>(())
71//! ```
72
73pub mod error;
74pub mod reader;
75pub mod writer;
76
77pub use error::{Result, SZipError};
78pub use reader::{StreamingZipReader, ZipEntry};
79pub use writer::{CompressionMethod, StreamingZipWriter};