Skip to main content

Crate oxiarc_zstd

Crate oxiarc_zstd 

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

BackwardBitWriter
Backward bitstream writer for FSE sequence encoding.
ForwardBitWriter
Forward bitstream writer (LSB first).
LevelConfig
Compression level configuration.
Lz77Sequence
LZ77 sequence: a literal run followed by an optional match.
MatchFinder
LZ77 match finder using hash chains.
ZstdDecoder
Zstandard decoder.
ZstdEncoder
Zstandard encoder.

Enums§

BlockType
Block types in Zstandard.
CompressionStrategy
Compression strategy for block encoding.
LiteralsBlockType
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_all pattern).
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_all pattern).
write_skippable_frame
Write a skippable Zstandard frame containing arbitrary user data.

Type Aliases§

ZstdWriter
Alias for ZstdStreamEncoder — a streaming writer that emits incremental Zstandard frames.