Expand description
This project is a 7z compressor/decompressor written in pure Rust.
sevenz-turbo is a fork of sevenz-rust2
(itself a fork of the unmaintained sevenz-rust). It differs from upstream
in two ways, and the module paths and public API are otherwise upstream’s:
- LZMA and LZMA2 decode - and, with
compress, encode - throughlzma-turbo, a port of the 7-Zip reference coders, instead of upstream’s pure-Rust coders. - It adds the container API a streaming consumer needs: memory limits enforced before allocation, per-member CRCs, folder-to-pack-stream byte ranges, a borrowing reader, typed corruption errors carrying a block index and packed offset, and a per-block completion hook.
PPMd also goes through a different engine,
ppmd-turbo, and the default
thread count, the cryptography backends and the limits on hostile archives
differ; the README lists them.
The CHANGELOG.md section “Fork” is the exhaustive divergence list.
§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 ARM | ✓ | ✓ |
| BCJ ARM64 | ✓ | ✓ |
| BCJ ARM_THUMB | ✓ | ✓ |
| BCJ RISC_V | ✓ | ✓ |
| BCJ PPC | ✓ | ✓ |
| BCJ SPARC | ✓ | ✓ |
| BCJ IA64 | ✓ | ✓ |
| BCJ2 | ✓ | ✓ |
| DELTA | ✓ | ✓ |
Re-exports§
pub use container::ArchiveLimits;pub use container::BlockCompletion;pub use container::PackStreamRange;pub use container::SubStream;pub use container::SubStreamCompletion;pub use container::UnsizedCoder;pub use container::coder_memory_estimate;
Modules§
- container
- Container-level questions a streaming consumer asks before it decodes.
- encoder_
options compress - Encoding options when compressing.
- hooks
crc-hostorcrypto-host - Embedder-supplied delegation hooks for the bulk AES-256-CBC decrypt, the
key derivation’s SHA-256 and the 7z CRC-32 (the
crypto-hostandcrc-hostfeatures). See the module documentation for the contract a host must satisfy. Embedder-supplied delegation hooks for the bulk cryptography and checksums.
Structs§
- AesKey
aes256 - An AES-256 key whose owned bytes are cleared on drop and never debug-printed.
- AesProperties
aes256 - Validated public parameters of a 7z AES-256-CBC coder.
- Archive
- Represents a parsed 7z archive structure.
- Archive
Entry - Represents a single file or directory entry within a 7z archive.
- Archive
Reader - Reads a 7z archive file.
- Archive
Writer compress - Writes a 7z archive file.
- Auto
Finisher - A wrapper around a writer that finishes the stream on drop.
- Block
- Represents a compression block.
- Block
Decoder - Decoder for a specific block within a 7z archive.
- Coder
- Represents a single coder within a compression block.
- CrcFolder
- Folds checksummed pieces into the checksum of any range they cover.
- Encoder
Configuration compress - Configuration for encoding methods when compressing data.
- Encoder
Method - Encoder method that can be chained (filter, compression and encryption).
- Lzma2
Handle - A live handle on the LZMA2 coder of whichever block is being decoded.
- Lzma2
Ledger - What the parallel LZMA2 decodes of one reader held, and how their runs went out to the worker threads.
- Lzma2
Progress - What the LZMA2 coder of the block being decoded is doing right now.
- Lzma2
RunCompletion - Completed decoding of one run. Bytes remain provisional until the folder’s header checksums are verified and the caller accepts the current epoch.
- Lzma2
RunCrc - A worker-computed CRC segment, in folder output coordinates.
- NtTime
- A type that represents a Windows file time and is used in the 7z archive format.
- Ordered
Coder Iter - Iterator that yields coders in their processing order within a block.
- Password
- A password used for password protected, encrypted files.
- Positional
Block Decoder - An owned block decode that can move to a caller’s worker pool.
- Positional
Lzma2 Folder - A pure LZMA2 folder whose runs can write independently on a caller’s pool.
- Positional
Lzma2 Run - One independently decodable, fully scanned run. Cloning permits a repair replay, but coverage and epoch validity must be re-established by the caller.
- Positional
Lzma2 Scanner - A bounded scanner that holds at most one completed run awaiting admission.
- Prepared
Block compress - A solid block compressed away from any writer, ready to be appended by
ArchiveWriter::push_prepared_block. - Read
AtCursor - A
Read+Seekover aReadAt, with a cursor of its own. - Serial
Read At - Any
Read+Seekas aReadAt, by taking turns: a lock around the reader is held for one seek and one read. - Source
Reader compress - A wrapper around a reader that tracks read count and CRC32.
- Stream
Map - Mapping structure that correlates files, blocks, and pack streams within an archive.
Enums§
- Block
Error Kind - What went wrong in an
Error::BlockDecode. - Error
- The error type of the crate.
- Limit
- Which bound an
Error::LimitExceededhit.
Constants§
- SIGNATURE_
HEADER_ SIZE - Size of the 7z signature header in bytes (32 bytes). This is needed for calculating absolute byte offsets within the archive.
Traits§
- Entry
Read - An entry’s bytes, as a
ArchiveReader::for_each_entries_directorBlockDecoder::for_each_entries_directcallback is handed them. - ReadAt
- A source of archive bytes that is read at an offset.
Functions§
- compress
compressandutiland non-WebAssembly - Compresses a source file or directory to a destination writer.
- compress_
encrypted aes256andcompressandutiland non-WebAssembly - Compresses a source file or directory to a destination writer with password encryption.
- compress_
to_ path compressandutiland non-WebAssembly - Compresses a source file or directory to a destination file path.
- compress_
to_ path_ encrypted aes256andcompressandutiland non-WebAssembly - Compresses a source file or directory to a destination file path with password encryption.
- crc32_
combine - Combines two CRC-32s: the checksum of
a ++ b, given the checksum of each piece and the length of the second. - crypto_
backend aes256 - Names the cryptography backend this build of the crate selected for the 7z
aes256coder:"aws-lc"or"rustcrypto". - decompress
utiland non-WebAssembly - Decompresses an archive from a reader to a destination directory.
- decompress_
file utiland non-WebAssembly - Decompresses an archive file to a destination directory.
- decompress_
file_ with_ extract_ fn utiland non-WebAssembly - Decompresses an archive file to a destination directory with a custom extraction function.
- decompress_
file_ with_ extract_ fn_ and_ limits utiland non-WebAssembly decompress_file_with_extract_fnwith explicit limits, checked before allocation and extraction. The callback owns filesystem safety for any writes it performs.- decompress_
file_ with_ limits utiland non-WebAssembly decompress_filewith explicit limits, checked before allocation and extraction.- decompress_
file_ with_ password aes256andutiland non-WebAssembly - Decompresses an encrypted archive file with the given password.
- decompress_
file_ with_ password_ and_ limits aes256andutiland non-WebAssembly decompress_file_with_passwordwith explicit limits, checked before allocation and extraction.- decompress_
with_ extract_ fn utiland non-WebAssembly - Decompresses an archive from a reader to a destination directory with a custom extraction function.
- decompress_
with_ extract_ fn_ and_ limits utiland non-WebAssembly decompress_with_extract_fnwith explicit limits, checked before allocation and extraction. The callback owns filesystem safety for any writes it performs.- decompress_
with_ extract_ fn_ and_ password aes256andutiland non-WebAssembly - Decompresses an encrypted archive from a reader with a custom extraction function and password.
- decompress_
with_ extract_ fn_ and_ password_ and_ limits aes256andutiland non-WebAssembly decompress_with_extract_fn_and_passwordwith explicit limits, checked before allocation and extraction. The callback owns filesystem safety for any writes it performs.- decompress_
with_ limits utiland non-WebAssembly decompresswith explicit limits, checked before allocation and extraction.- decompress_
with_ password aes256andutiland non-WebAssembly - Decompresses an encrypted archive from a reader with the given password.
- decompress_
with_ password_ and_ limits aes256andutiland non-WebAssembly decompress_with_passwordwith explicit limits, checked before allocation and extraction.- default_
entry_ extract_ fn utiland non-WebAssembly - Default extraction function that handles standard file and directory extraction.
- lzma_
encoder compress - Names the LZMA and LZMA2 encoder this crate writes archives with:
"lzma-turbo". - prepare_
block compress - Compress
entriesinto one solid block usingmethods, without a writer. - sha256
aes256 - The SHA-256 of
data, computed by the backendcrypto_backendnames.