Crates.io | yazi |
lib.rs | yazi |
version | 0.2.0 |
source | src |
created_at | 2020-03-24 06:24:31.584433 |
updated_at | 2023-11-29 04:44:58.328066 |
description | DEFLATE/zlib compression and decompression. |
homepage | https://github.com/dfrg/yazi |
repository | https://github.com/dfrg/yazi |
max_upload_size | |
id | 222062 |
size | 145,400 |
Yazi is a pure Rust implementation of the RFC 1950 DEFLATE specification with support for the zlib wrapper. It provides streaming compression and decompression.
The following demonstrates simple usage for compressing and decompressing in-memory buffers:
use yazi::*;
// Your source data.
let data = &(0..=255).cycle().take(8192).collect::<Vec<u8>>()[..];
// Compress it into a Vec<u8> with a zlib wrapper using the default compression level.
let compressed = compress(data, Format::Zlib, CompressionLevel::Default).unwrap();
// Decompress it into a Vec<u8>.
let (decompressed, checksum) = decompress(&compressed, Format::Zlib).unwrap();
// Verify the checksum.
assert_eq!(Adler32::from_buf(&decompressed).finish(), checksum.unwrap());
// Verify that the decompressed data matches the original.
assert_eq!(data, &decompressed[..]);
For detail on more advanced usage, see the full API documentation.