| Crates.io | mismall |
| lib.rs | mismall |
| version | 2.0.0 |
| created_at | 2026-01-25 20:30:15.896492+00 |
| updated_at | 2026-01-25 20:30:15.896492+00 |
| description | Streaming Huffman compression library with AES-256-GCM encryption and archive support |
| homepage | |
| repository | https://github.com/gnik-snrub/make_it_small?branch=ai-library-transformation |
| max_upload_size | |
| id | 2069479 |
| size | 570,712 |
A sophisticated Rust library for file compression and decompression built around canonical Huffman coding with streaming architecture. Designed to handle arbitrarily large files with bounded memory usage and optional AES-256-GCM encryption.
Add this to your Cargo.toml:
[dependencies]
mismall = "2.0"
.small containers with metadata--chunk-size flaguse mismall::{compress_stream, decompress_stream};
use std::io::Cursor;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create test data
let input_data = b"Hello, world! This is test data for compression.";
std::fs::write("test.txt", input_data)?;
// Compress using stream API
let mut reader = Cursor::new(input_data);
let mut compressed = Vec::new();
let result = mismall::compress_stream(&mut reader, "test.txt", None, &mut compressed, 1024 * 1024)?;
println!("Compressed {} -> {} bytes ({:.1}% ratio)",
result.original_size, result.compressed_size, result.compression_ratio);
// Save compressed data
std::fs::write("test.txt.small", compressed)?;
// Decompress the file
let compressed_data = std::fs::read("test.txt.small")?;
let mut compressed_reader = Cursor::new(compressed_data);
let mut decompressed = Vec::new();
let result = mismall::decompress_stream(&mut compressed_reader, None, &mut decompressed, 1024 * 1024)?;
println!("Decompressed {} bytes", result.original_size);
Ok(())
}
compression (default): Compression and decompression functionalityarchives (default): Multi-file archive operationsencryption (default): AES-256-GCM encryption supportcli: Command-line interface (enables all other features)[dependencies]
mismall = { version = "2.0", default-features = false, features = ["compression", "encryption"] }
compress_stream()] - Compress data streams with custom settingsdecompress_stream()] - Decompress data streams with custom settingsCompressionBuilder] - Advanced compression with optionsDecompressionBuilder] - Advanced decompression with optionsArchiveBuilder] - Create multi-file archivesArchiveExtractor] - Extract from archives with optionsstream_reader()] - Read from compressed streamsstream_writer()] - Write to compressed streamsCompressor] - Stateful streaming compressionDecompressor] - Stateful streaming decompressionThe examples/ directory contains comprehensive library examples:
simple_compress.rs - Basic compression and decompressionadvanced_compression.rs - Compression with encryption and custom settingsarchive_operations.rs - Multi-file archive creation and extractionstreaming.rs - Real-time streaming compression/decompressionperformance.rs - Performance comparison and benchmarksRun examples with:
cargo run --example simple_compress
cargo run --example advanced_compression
cargo run --example archive_operations
cargo run --example streaming
cargo run --example performance
For comprehensive performance optimization guidance, see PERFORMANCE.md:
All library functions return Result<T, MismallError> where MismallError provides detailed error information with context for troubleshooting.
match mismall::compress_stream(&mut reader, "test.txt", None, &mut output, 1024 * 1024) {
Ok(result) => println!("Success: {} bytes compressed", result.compressed_size),
Err(e) => eprintln!("Compression failed: {}", e),
}
The mismall library also includes a command-line interface. Install and use as follows:
Compress (with optional encryption and ratio display):
mismall compress [-r] [-p PASSWORD] [--chunk-size SIZE] <INPUT> [OUTPUT_BASENAME]
OUTPUT_BASENAME is omitted: output is <INPUT>.small<OUTPUT_BASENAME>.small--chunk-size: Memory usage (default 16MB, min 64KB recommended)-p: Optional password for AES-256-GCM encryptionDecompress:
mismall decompress [-p PASSWORD] [--chunk-size SIZE] <INPUT.small> [OUTPUT_NAME]
OUTPUT_NAME is omitted: restores original filename from header--chunk-size: Memory usage for decryption operationsCreate archive from directory:
mismall compress [-r] [-p PASSWORD] [--chunk-size SIZE] <DIRECTORY> [ARCHIVE_NAME]
List archive contents:
mismall list <ARCHIVE.small>
Extract from archive:
mismall extract-file [-p PASSWORD] [--chunk-size SIZE] <ARCHIVE.small> <FILENAME> [OUTPUT_NAME]
--chunk-size 65536 (64KB)--chunk-size 1073741824 (1GB)chunk-size + small overhead (~50KB)HTML (~4.5 MiB)
Ratio: 73% (to 3.3 MiB)
Encode: 92 ms. Decode: 80 ms.
Source file (~4.4 KiB)
Ratio: 63% (to 2.8 KiB)
Times: sub-millisecond
Binary (~5.5 MiB)
Ratio: 82% (to 4.5 MiB)
Encode: 108 ms. Decode: 99 ms.
Binary (~82 MiB)
Ratio: 80% (to 65 MiB)
Encode: 1.6 s. Decode: 1.46 s.
Mismall ships with a comprehensive test suite (66 tests) covering:
Run all tests with:
cargo test
# Basic compression with ratio
mismall compress -r document.txt
# Compressed with encryption and custom chunk size
mismall compress -p mypassword --chunk-size 8388608 large_video.mp4 encrypted_archive.small
# Decompress with password
mismall decompress -p mypassword encrypted_archive.small
# Create archive from directory
mismall compress project/ project_archive
# Extract specific file from archive
mismall extract-file project_archive.small src/main.rs main_backup.rs
# List archive contents
mismall list project_archive.small
MIT — do whatever you want, just don't claim you wrote it.
The original hand-crafted CLI implementation remains available as legacy version.
git clone https://github.com/gnik-snrub/make_it_small.git
cd make_it_small
git checkout f44054c9c7dd4813a5cdd41bbe8da2933409caa7
cargo install --path .
cargo install mismall --locked --git https://github.com/gnik-snrub/make_it_small.git --branch main
cargo install mismall --locked --git https://github.com/gnik-snrub/make_it_small.git --branch legacy-cli
Main Branch: Shows original hand-crafted CLI work (commit f44054c)
AI Branch: Modern library transformation (ai-library-transformation)
Cargo Integration: Points to AI branch automatically via Cargo.toml
This means:
The transformation preserved all original concepts while adding comprehensive library capabilities.