Expand description
§OxiArc LZMA
LZMA (Lempel-Ziv-Markov chain Algorithm) compression and decompression.
LZMA is a lossless data compression algorithm that provides excellent compression ratios. It’s used in:
- 7-Zip archives (.7z)
- XZ compressed files (.xz)
- LZMA-compressed files (.lzma)
- Some ZIP archives (method 14)
§Features
- Pure Rust implementation
- Decompression of LZMA streams
- Compression with configurable levels
- Range coder for entropy coding
- Probability-based context modeling
§Usage
§Decompression
ⓘ
use oxiarc_lzma::decompress;
let compressed = include_bytes!("data.lzma");
let decompressed = decompress(&compressed[..])?;§Compression
ⓘ
use oxiarc_lzma::{compress, LzmaLevel};
let data = b"Hello, World!";
let compressed = compress(data, LzmaLevel::DEFAULT)?;§LZMA2 Chunked Encoding (XZ compatible)
ⓘ
use oxiarc_lzma::{encode_lzma2_chunked, decode_lzma2_chunked, LzmaLevel};
let data = b"Hello, LZMA2 chunked world!";
let encoded = encode_lzma2_chunked(data, LzmaLevel::DEFAULT)?;
let decoded = decode_lzma2_chunked(&encoded, 1 << 20)?;For custom chunk sizes, use Lzma2ChunkedEncoder:
ⓘ
use oxiarc_lzma::{Lzma2ChunkedEncoder, Lzma2Config, LzmaLevel};
let config = Lzma2Config::with_level(LzmaLevel::DEFAULT).chunk_size(64 * 1024);
let mut encoder = Lzma2ChunkedEncoder::with_config(config);
let encoded = encoder.encode(data)?;§LZMA Format
An LZMA stream consists of:
- Properties byte (lc, lp, pb encoded)
- Dictionary size (4 bytes, little-endian)
- Uncompressed size (8 bytes, little-endian, 0xFFFFFFFFFFFFFFFF = unknown)
- Compressed data
The algorithm uses:
- LZ77-style dictionary compression with sliding window
- Range coding for entropy encoding
- Context-dependent probability models
Re-exports§
pub use decoder::LzmaDecoder;pub use decoder::decompress;pub use decoder::decompress_raw;pub use encoder::LzmaEncoder;pub use encoder::compress;pub use encoder::compress_raw;pub use lzma2::Lzma2Decoder;pub use lzma2::Lzma2Encoder;pub use lzma2::decode_lzma2;pub use lzma2::dict_size_from_props;pub use lzma2::encode_lzma2;pub use lzma2::props_from_dict_size;pub use lzma2_chunk::ChunkType;pub use lzma2_chunk::DEFAULT_CHUNK_SIZE;pub use lzma2_chunk::LZMA_CHUNK_MAX_COMPRESSED;pub use lzma2_chunk::LZMA_CHUNK_MAX_UNCOMPRESSED;pub use lzma2_chunk::Lzma2ChunkedEncoder;pub use lzma2_chunk::Lzma2Config;pub use lzma2_chunk::UNCOMPRESSED_CHUNK_MAX;pub use lzma2_chunk::control;pub use lzma2_chunk::decode_lzma2_chunked;pub use lzma2_chunk::encode_lzma2_chunked;pub use lzma2_chunk::encode_lzma2_with_config;pub use lzma2_stream::Lzma2StreamDecoder;pub use lzma2_stream::Lzma2StreamEncoder;pub use match_finder::Bt4MatchFinder;pub use match_finder::HashChainMatchFinder;pub use match_finder::MatchFinder;pub use memory_pool::LzmaDecoderPooled;pub use memory_pool::LzmaPool;pub use memory_pool::PooledBuf;pub use memory_pool::bucket_for;pub use model::LzmaModel;pub use model::LzmaProperties;pub use model::State;pub use range_coder::RangeDecoder;pub use range_coder::RangeEncoder;pub use streaming::LZMA_COMPRESSOR_DEFAULT_BUDGET;pub use streaming::LZMA_DECOMPRESSOR_DEFAULT_BUDGET;pub use streaming::LzmaCompressor;pub use streaming::LzmaDecompressor;
Modules§
- decoder
- LZMA decompression.
- encoder
- LZMA compression.
- lzma2
- LZMA2 codec for XZ files.
- lzma2_
chunk - LZMA2 chunking support.
- lzma2_
stream - Bounded-memory true streaming for LZMA2.
- match_
finder - Match finder implementations for LZMA compression.
- memory_
pool - Thread-safe memory pool for LZMA dictionary buffers.
- model
- LZMA probability models.
- optimal
- Optimal parsing for LZMA compression.
- range_
coder - Range coder for LZMA compression.
- streaming
- Bounded-memory LZMA streaming compressor and decompressor.
Structs§
- Lzma
Level - LZMA compression level.
Enums§
- Error
- Re-export of the core error type for convenient use in tests and downstream crates. The main error type for OxiArc operations.
Functions§
- compress_
bytes - Compress data to a Vec using default settings.
- decompress_
bytes - Decompress LZMA data to a Vec.
- lzma2_
compress - Compress data to an LZMA2 stream using the given numeric compression level.
- lzma2_
decompress - Decompress an LZMA2 stream produced by
lzma2_compressorLzmaCompressor::compress.