This project is a 7z compressor/decompressor written in pure Rust.
This is a fork of the original, unmaintained sevenz-rust crate to continue the development and maintenance.
Supported Codecs & filters
| Codec | Decompression | Compression |
|---|---|---|
| COPY | ✓ | ✓ |
| LZMA | ✓ | ✓ |
| LZMA2 | ✓ | ✓ |
| BROTLI (*) | ✓ | ✓ |
| BZIP2 | ✓ | ✓ |
| DEFLATE (*) | ✓ | ✓ |
| PPMD | ✓ | ✓ |
| LZ4 (*) | ✓ | ✓ |
| ZSTD (*) | ✓ | ✓ |
(*) Require optional cargo feature.
| Filter | Decompression | Compression |
|---|---|---|
| BCJ X86 | ✓ | |
| BCJ PPC | ✓ | |
| BCJ IA64 | ✓ | |
| BCJ ARM | ✓ | |
| BCJ ARM64 | ✓ | |
| BCJ ARM_THUMB | ✓ | |
| BCJ SPARC | ✓ | |
| DELTA | ✓ | ✓ |
| BCJ2 | ✓ |
Usage
[]
= { = "0.16" }
Decompress source file "data/sample.7z" to destination path "data/sample":
decompress_file.expect;
Decompress an encrypted 7z file
Use the helper function to encrypt and decompress source file "path/to/encrypted.7z" to destination path "data/sample":
decompress_file_with_password.expect;
Compression
Use the helper function to create a 7z file with source path:
compress_to_path.expect;
Compress with AES encryption
Use the helper function to create a 7z file with source path and password:
compress_to_path_encrypted.expect;
Advanced Usage
Solid compression
Solid archives can in theory provide better compression rates, but decompressing a file needs all previous data to also be decompressed.
use *;
let mut writer = create.expect;
writer.push_source_path.expect;
writer.finish.expect;
Configure the compression methods
With encryption and lzma2 options:
use *;
let mut writer = create.expect;
writer.set_content_methods;
writer.push_source_path.expect;
writer.finish.expect;
WASM support
WASM is supported, but you can't use the default features. We provide a "default_wasm" feature that contains all default features with the needed changes to support WASM:
RUSTFLAGS='--cfg getrandom_backend="wasm_js"'
Licence
Licensed under the Apache License, Version 2.0.