Expand description
LZMA / LZMA2 / LZIP / XZ compression ported from tukaani xz for java.
This is a fork of the original, unmaintained lzma-rust crate to continue the development and maintenance.
§Safety
Only the optimization
feature uses unsafe Rust features to implement optimizations, that are
not possible in safe Rust. Those optimizations are properly guarded and are of course sound.
This includes creation of aligned memory, handwritten assembly code for hot functions and some
pointer logic. Those optimization are well localized and generally consider safe to use, even
with untrusted input.
Deactivating the optimization
feature will result in 100% standard Rust code.
§Performance
When compared against the liblzma
crate, which uses the C library of the same name, this crate
has improved decoding speed.
Encoding is also well optimized and is surpassing liblzma
for level 0 to 3 and matches it for
level 4 to 9.
§no_std Support
This crate supports no_std
environments by disabling the default std
feature.
When used in no_std
mode, the crate provides custom Read
, Write
, and Error
types
(defined in no_std.rs
) that are compatible with no_std
environments. These types offer
similar functionality to their std::io
counterparts but are implemented using only core
and alloc
.
The custom types include:
Error
: A custom error enum with variants for different error conditions.Read
: A trait similar tostd::io::Read
withread()
andread_exact()
methods.Write
: A trait similar tostd::io::Write
withwrite()
,write_all()
, andflush()
methods.
Default implementations for &[u8]
(Read) and &mut [u8]
(Write) are provided.
Note that multithreaded features are not available in no_std
mode as they require
standard library threading primitives.
§License
Licensed under the Apache License, Version 2.0.
Modules§
- filter
- Implements filter used by both the 7z and XZ file format.
Structs§
- Auto
Finisher - A wrapper around a writer that finishes the stream on drop.
- Filter
Config xz
- Configuration for a filter in the XZ filter chain.
- Lzip
Options encoder
andlzip
- Options for LZIP compression.
- Lzip
Reader lzip
- A single-threaded LZIP decompressor.
- Lzip
Reader Mt std
andlzip
- A multi-threaded LZIP decompressor.
- Lzip
Writer encoder
andlzip
- A single-threaded LZIP compressor.
- Lzip
Writer Mt encoder
andstd
andlzip
- A multi-threaded LZIP compressor.
- Lzma2
Options encoder
- Options for LZMA2 compression.
- Lzma2
Reader - A single-threaded LZMA2 decompressor.
- Lzma2
Reader Mt std
- A multi-threaded LZMA2 decompressor.
- Lzma2
Writer encoder
- A single-threaded LZMA2 compressor.
- Lzma2
Writer Mt std
andencoder
- A multi-threaded LZMA2 compressor.
- Lzma
Options encoder
- Encoder settings when compressing with LZMA and LZMA2.
- Lzma
Reader - A single-threaded LZMA decompressor.
- Lzma
Writer encoder
- A single-threaded LZMA compressor.
- XzOptions
encoder
andxz
- Configuration options for XZ compression.
- XzReader
xz
- A single-threaded XZ decompressor.
- XzReader
Mt std
andxz
- A multi-threaded XZ decompressor.
- XzWriter
encoder
andxz
- A single-threaded XZ compressor.
- XzWriter
Mt encoder
andstd
andxz
- A multi-threaded XZ compressor.
Enums§
- Check
Type xz
- Supported checksum types in XZ format.
- Encode
Mode encoder
- The mode to use when encoding.
- Filter
Type xz
- Supported filter types in XZ format.
- MfType
- Match finders to use when encoding.
Constants§
- DICT_
SIZE_ MAX - The maximal size of a dictionary.
- DICT_
SIZE_ MIN - The minimal size of a dictionary.
Functions§
- get_
extra_ size_ before encoder
- Calculates the extra space needed before the dictionary for LZMA2 encoding.
- lzma2_
get_ memory_ usage - Calculates the memory usage in KiB required for LZMA2 decompression.
- lzma_
get_ memory_ usage - Calculates the memory usage in KiB required for LZMA decompression.
- lzma_
get_ memory_ usage_ by_ props - Calculates the memory usage in KiB required for LZMA decompression from properties byte.
Type Aliases§
- Result
std
- Result type of the crate.