Skip to main content

Crate sevenz_turbo

Crate sevenz_turbo 

Source
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:

  1. LZMA and LZMA2 decode - and, with compress, encode - through lzma-turbo, a port of the 7-Zip reference coders, instead of upstream’s pure-Rust coders.
  2. 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

CodecDecompressionCompression
COPY✓✓
LZMA✓✓
LZMA2✓✓
BROTLI (*)✓✓
BZIP2✓✓
DEFLATE (*)✓✓
PPMD✓✓
LZ4 (*)✓✓
ZSTD (*)✓✓

(*) Require optional cargo feature.

FilterDecompressionCompression
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_optionscompress
Encoding options when compressing.
hookscrc-host or crypto-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-host and crc-host features). See the module documentation for the contract a host must satisfy. Embedder-supplied delegation hooks for the bulk cryptography and checksums.

Structs§

AesKeyaes256
An AES-256 key whose owned bytes are cleared on drop and never debug-printed.
AesPropertiesaes256
Validated public parameters of a 7z AES-256-CBC coder.
Archive
Represents a parsed 7z archive structure.
ArchiveEntry
Represents a single file or directory entry within a 7z archive.
ArchiveReader
Reads a 7z archive file.
ArchiveWritercompress
Writes a 7z archive file.
AutoFinisher
A wrapper around a writer that finishes the stream on drop.
Block
Represents a compression block.
BlockDecoder
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.
EncoderConfigurationcompress
Configuration for encoding methods when compressing data.
EncoderMethod
Encoder method that can be chained (filter, compression and encryption).
Lzma2Handle
A live handle on the LZMA2 coder of whichever block is being decoded.
Lzma2Ledger
What the parallel LZMA2 decodes of one reader held, and how their runs went out to the worker threads.
Lzma2Progress
What the LZMA2 coder of the block being decoded is doing right now.
Lzma2RunCompletion
Completed decoding of one run. Bytes remain provisional until the folder’s header checksums are verified and the caller accepts the current epoch.
Lzma2RunCrc
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.
OrderedCoderIter
Iterator that yields coders in their processing order within a block.
Password
A password used for password protected, encrypted files.
PositionalBlockDecoder
An owned block decode that can move to a caller’s worker pool.
PositionalLzma2Folder
A pure LZMA2 folder whose runs can write independently on a caller’s pool.
PositionalLzma2Run
One independently decodable, fully scanned run. Cloning permits a repair replay, but coverage and epoch validity must be re-established by the caller.
PositionalLzma2Scanner
A bounded scanner that holds at most one completed run awaiting admission.
PreparedBlockcompress
A solid block compressed away from any writer, ready to be appended by ArchiveWriter::push_prepared_block.
ReadAtCursor
A Read + Seek over a ReadAt, with a cursor of its own.
SerialReadAt
Any Read + Seek as a ReadAt, by taking turns: a lock around the reader is held for one seek and one read.
SourceReadercompress
A wrapper around a reader that tracks read count and CRC32.
StreamMap
Mapping structure that correlates files, blocks, and pack streams within an archive.

Enums§

BlockErrorKind
What went wrong in an Error::BlockDecode.
Error
The error type of the crate.
Limit
Which bound an Error::LimitExceeded hit.

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§

EntryRead
An entry’s bytes, as a ArchiveReader::for_each_entries_direct or BlockDecoder::for_each_entries_direct callback is handed them.
ReadAt
A source of archive bytes that is read at an offset.

Functions§

compresscompress and util and non-WebAssembly
Compresses a source file or directory to a destination writer.
compress_encryptedaes256 and compress and util and non-WebAssembly
Compresses a source file or directory to a destination writer with password encryption.
compress_to_pathcompress and util and non-WebAssembly
Compresses a source file or directory to a destination file path.
compress_to_path_encryptedaes256 and compress and util and 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_backendaes256
Names the cryptography backend this build of the crate selected for the 7z aes256 coder: "aws-lc" or "rustcrypto".
decompressutil and non-WebAssembly
Decompresses an archive from a reader to a destination directory.
decompress_fileutil and non-WebAssembly
Decompresses an archive file to a destination directory.
decompress_file_with_extract_fnutil and non-WebAssembly
Decompresses an archive file to a destination directory with a custom extraction function.
decompress_file_with_extract_fn_and_limitsutil and non-WebAssembly
decompress_file_with_extract_fn with explicit limits, checked before allocation and extraction. The callback owns filesystem safety for any writes it performs.
decompress_file_with_limitsutil and non-WebAssembly
decompress_file with explicit limits, checked before allocation and extraction.
decompress_file_with_passwordaes256 and util and non-WebAssembly
Decompresses an encrypted archive file with the given password.
decompress_file_with_password_and_limitsaes256 and util and non-WebAssembly
decompress_file_with_password with explicit limits, checked before allocation and extraction.
decompress_with_extract_fnutil and non-WebAssembly
Decompresses an archive from a reader to a destination directory with a custom extraction function.
decompress_with_extract_fn_and_limitsutil and non-WebAssembly
decompress_with_extract_fn with explicit limits, checked before allocation and extraction. The callback owns filesystem safety for any writes it performs.
decompress_with_extract_fn_and_passwordaes256 and util and non-WebAssembly
Decompresses an encrypted archive from a reader with a custom extraction function and password.
decompress_with_extract_fn_and_password_and_limitsaes256 and util and non-WebAssembly
decompress_with_extract_fn_and_password with explicit limits, checked before allocation and extraction. The callback owns filesystem safety for any writes it performs.
decompress_with_limitsutil and non-WebAssembly
decompress with explicit limits, checked before allocation and extraction.
decompress_with_passwordaes256 and util and non-WebAssembly
Decompresses an encrypted archive from a reader with the given password.
decompress_with_password_and_limitsaes256 and util and non-WebAssembly
decompress_with_password with explicit limits, checked before allocation and extraction.
default_entry_extract_fnutil and non-WebAssembly
Default extraction function that handles standard file and directory extraction.
lzma_encodercompress
Names the LZMA and LZMA2 encoder this crate writes archives with: "lzma-turbo".
prepare_blockcompress
Compress entries into one solid block using methods, without a writer.
sha256aes256
The SHA-256 of data, computed by the backend crypto_backend names.