| Crates.io | bunko |
| lib.rs | bunko |
| version | 0.1.1 |
| created_at | 2024-12-02 05:50:25.214393+00 |
| updated_at | 2024-12-03 10:00:48.286431+00 |
| description | bunko is a lightweight, flexible, high-performance Rust library for data compression and decompression. |
| homepage | https://github.com/reinacchi/bunko |
| repository | |
| max_upload_size | |
| id | 1468299 |
| size | 25,192 |
bunko is a lightweight, flexible, and high-performance Rust library for data compression and decompression. bunko simplifies handling Gzip, Zlib and Deflate compression in both single-pass and streaming modes while leveraging Rust's safety and performance.
Built with Rust, bunko offers incredible performance with low overhead.
No manual memory management, ensuring safety at every step.
Designed to be intuitive, whether you're compressing small strings or handling large data streams.
Add bunko to your Cargo.toml:
[dependencies]
bunko = "0.1.0"
use bunko::{compress_string, decompress_to_string, CompressionLevel};
fn main() {
let input = "Hello, Bunko!";
println!("Original: {}", input);
// Compress the string
let compressed = compress_string(input, CompressionLevel::Best)
.expect("Failed to compress string");
println!("Compressed size: {} bytes", compressed.len());
// Decompress the string
let decompressed = decompress_to_string(&compressed)
.expect("Failed to decompress string");
println!("Decompressed: {}", decompressed);
assert_eq!(input, decompressed);
}
use bunko::{calculate_compression_ratio, compress_with_buffer, BunkoError, CompressionFormat, CompressionLevel};
fn main() -> Result<(), BunkoError> {
let input = b"Hello, this is a test for buffer streaming!".repeat(1000);
let compressed = compress_with_buffer(
&input,
CompressionFormat::Deflate,
CompressionLevel::Best,
1024, // Buffer size
)?;
let ratio = calculate_compression_ratio(input.len(), compressed.len());
println!("Uncompressed size: {} bytes", input.len());
println!("Compression size: {} bytes", compressed.len());
println!("Compression ratio: {:.2}%", ratio * 100.0);
Ok(())
}
This library is licensed under MIT.