Releases: muhammad-fiaz/zstd.zig
Release list
v0.0.3
This release significantly improves the existing native Zstandard implementation introduced in v0.0.2, completing the remaining compression and decompression functionality, improving compression efficiency, and covering previously missing edge cases.
The implementation continues to be pure Zig with zero C dependencies, with expanded support for the Zstandard 1.6.0 specification.
Compression Improvements
- Improved the existing native LZ77 compression implementation.
- Added FSE sequence encoding and improved sequence bitstream generation.
- Added repeat-offset sequence encoding with complete three-entry repeat-offset history tracking.
- Improved compression of repetitive and structured data.
- Added repeat-offset handling for distances 1–3.
- Added raw and RLE block fallback when compression does not provide a benefit.
- Added RLE detection.
- Improved compression-level support for levels 1–22 and negative levels.
- Expanded configurable compression parameters including strategy, window size, hash/chain depth, search length, minimum match length, and target length.
Decompression Improvements
- Completed compressed-block decoding functionality.
- Added Huffman literal decoding for single-stream and 4-stream modes.
- Added FSE sequence decoding for predefined, RLE, compressed, and repeat modes.
- Added compact normalized-counter header parsing with run-length zero coding.
- Improved repeat-offset semantics, including
litLength == 0edge cases. - Preserved entropy tables and repeat-offset history correctly across blocks.
- Added XXH64 checksum validation.
- Added content-size verification.
- Added dictionary ID handling.
- Added skippable-frame support.
- Added reserved frame-header descriptor validation.
Streaming Improvements
- Improved streaming decompression for fragmented frame headers.
- Frame-header parsing now determines the exact required header length before parsing.
- Incomplete headers correctly wait for additional input instead of failing.
- Improved handling of very small streaming chunks.
Edge-Case Coverage
Expanded coverage for previously missing and difficult cases, including:
- Empty inputs and frames.
- Input lengths from 0–300 bytes.
- Maximum single-block input.
- Multi-block frames.
- Checksum corruption.
- Mid-stream corruption.
- Skippable frames and all supported skippable magic variants.
- Skippable frames interleaved with data frames.
- Reserved frame-header bits.
- Content-size mismatches.
- Dictionary ID propagation.
- Streaming chunk boundaries.
- Empty final streaming chunks.
- Compression-level bounds.
compressBound()behavior.- Repeat-offset and literal-length-zero edge cases.
Versioning
Library and specification versions are now tracked separately:
- Library version: 0.0.3
- Zstandard specification: 1.6.0
- Specification version number: 10600
New specification-version accessors have also been added.
Documentation & Project Cleanup
- Updated documentation to explicitly describe Zstandard 1.6.0 support.
- Updated API documentation with separate library and specification versions.
- Added documentation for all 12 examples.
- Refreshed example outputs.
- Added
SECURITY.md. - Removed obsolete placeholder modules.
- Removed the old external test structure in favor of inline module tests.
- Removed the temporary reference C implementation after development and verification.
v0.0.2
This release replaces the previous C-based implementation with a native Zig implementation of Zstandard.
The implementation targets Zstandard 1.6.0 and Zig 0.16.0, with the codec and supporting functionality organized into dedicated Zig modules.
Highlights
- Complete native Zig implementation of Zstandard
- No C or
libzstddependency - Native compression and decompression
- Zstandard frame and block handling
- Raw, RLE, and compressed block support
- Huffman and FSE entropy coding
- Native bitstream implementation
- xxHash checksum support
- Streaming compression and decompression
- Compression and decompression contexts
- Dictionary support
- COVER and FastCover dictionary building
- Legacy Zstandard v0.1–v0.7 detection and support
- Redesigned public API
- Updated examples, tests, CI, and documentation
Format Support
The implementation covers the core Zstandard format, including frame headers, content sizes, window descriptors, dictionary IDs, checksums, skippable frames, block headers, block types, and frame boundaries.
Raw, RLE, and compressed blocks are handled through the native block codec, with Huffman and FSE support for entropy-coded data.
Streaming and Dictionaries
Native streaming support is provided through compression and decompression streams and reusable contexts.
Dictionary functionality includes dictionary loading, dictionary IDs, dictionary compression/decompression, dictionary building, COVER, and FastCover.
Legacy frame detection for Zstandard v0.1 through v0.7 is also included.
API
The public API has been redesigned around:
src/zstd.zig
The public surface is separated from the internal implementation modules, which are organized under src/common, src/compress, src/decompress, src/frame, src/fse, src/huffman, src/streaming, src/dictionary, and src/legacy.
Zig 0.16
The project now targets Zig 0.16.0.
Examples and filesystem operations have been updated to use the Zig 0.16 std.Io API, including the new file compression example.
Verification
221/221 tests passed
23/23 build steps successful
12/12 examples passed
Zig → Python: 18/18 interoperability tests passed
Python → Zig raw frames: 7/7 interoperability tests passed
The interoperability tests cover raw and RLE data, different input sizes, Unicode data, frame handling, and checksummed frames.
Breaking Changes
The previous C-based implementation has been removed from the package build. zstd.zig is now built entirely from the native Zig implementation.
The minimum supported Zig version is 0.16.0, and consumers should use the redesigned API exposed through src/zstd.zig.
Documentation
The README, API reference, guides, examples, contribution documentation, and documentation site have been updated to reflect the new native implementation and project structure.
v0.0.1
zstd.zig v0.0.1
Initial release of Zig bindings for the zstd (Zstandard) compression library.
What's New
- Complete Zig 0.16.0 bindings for zstd 1.6.0
- Full coverage of the zstd C API:
zstd.h,zstd_errors.h,zdict.h - All APIs re-exported at root level — use
zstd.compress(),zstd.decompress(), etc. directly
API Modules
| Module | Description |
|---|---|
simple |
One-shot compress/decompress |
cctx |
Compression context with full parameter control |
dctx |
Decompression context with full parameter control |
stream |
Streaming compression/decompression for large data |
dict |
Dictionary compression with CDict/DDict |
zdict |
Dictionary builder (ZDICT) for training from samples |
errors |
Unified Zig error set for all zstd error codes |
version |
Library version and capability queries |
Quick Start
const zstd = @import("zstd");
const compressed = try zstd.compress(allocator, data, 3);
defer allocator.free(compressed);
const decompressed = try zstd.decompress(allocator, compressed, data.len);
defer allocator.free(decompressed);