Expand description
§OxiArc Zstandard
Pure Rust implementation of the Zstandard (zstd) compression format (RFC 8878).
Zstandard is a modern, fast compression algorithm providing excellent compression ratios. This implementation provides full compression and decompression support.
§Features
- Full LZ77 + Huffman + FSE compression (levels 1-22)
- Complete Zstandard frame parsing and decompression
- FSE (Finite State Entropy) encoding and decoding
- Huffman encoding and decoding for literals
- Dictionary-based compression for small data
- Streaming Write/Read API
- XXH64 checksum verification
- Optional parallel compression
§Example
use oxiarc_zstd::{compress_with_level, decompress, encode_all, decode_all};
// Buffer-based compression with level
let data = b"Hello, Zstandard!";
let compressed = compress_with_level(data, 3).unwrap();
let decompressed = decompress(&compressed).unwrap();
assert_eq!(decompressed, data);
// Convenience functions (zstd crate compatible pattern)
let compressed = encode_all(data, 3).unwrap();
let decompressed = decode_all(&compressed).unwrap();
assert_eq!(decompressed, data);Re-exports§
pub use streaming::ZstdStreamDecoder;pub use streaming::ZstdStreamEncoder;pub use dict::ZstdDict;pub use dict::train_dictionary;
Modules§
- dict
- Dictionary support for improved compression of small data. Dictionary support for Zstandard compression.
- streaming
- Streaming compression and decompression. Streaming compression and decompression for Zstandard.
Structs§
- Backward
BitWriter - Backward bitstream writer for FSE sequence encoding.
- Forward
BitWriter - Forward bitstream writer (LSB first).
- Level
Config - Compression level configuration.
- Lz77
Sequence - LZ77 sequence: a literal run followed by an optional match.
- Match
Finder - LZ77 match finder using hash chains.
- Zstd
Decoder - Zstandard decoder.
- Zstd
Encoder - Zstandard encoder.
Enums§
- Block
Type - Block types in Zstandard.
- Compression
Strategy - Compression strategy for block encoding.
- Literals
Block Type - Literals block type.
Constants§
- MAX_
BLOCK_ SIZE - Maximum block size (128 KB).
- MAX_
WINDOW_ SIZE - Maximum window size (8 MB default, 2 GB max per spec).
- SKIPPABLE_
MAGIC_ HIGH - Skippable frame magic number range end (0x184D2A5F).
- SKIPPABLE_
MAGIC_ LOW - Skippable frame magic number range start (0x184D2A50).
- ZSTD_
MAGIC - Zstandard magic number (0xFD2FB528 little-endian).
Functions§
- compress
- Compress data using default settings (raw/RLE blocks, level 0).
- compress_
no_ checksum - Compress data without checksum.
- compress_
with_ level - Compress data with a specific compression level (1-22).
- decode_
all - Convenience function: decompress data (compatible with
zstd::decode_allpattern). - decompress
- Decompress Zstandard data.
- decompress_
frame - Decompress a single Zstandard frame, returning the decompressed data and
the number of bytes consumed from
data. - decompress_
multi_ frame - Decompress one or more concatenated Zstandard frames.
- decompress_
with_ dict - Decompress Zstandard data using a dictionary.
- encode_
all - Convenience function: compress data and return bytes (compatible with
zstd::encode_allpattern). - write_
skippable_ frame - Write a skippable Zstandard frame containing arbitrary user data.
Type Aliases§
- Zstd
Writer - Alias for
ZstdStreamEncoder— a streaming writer that emits incremental Zstandard frames.