v0.0.1
brotli.zig 0.0.1
Initial release of high-level Zig bindings for Google's Brotli compression library (RFC 7932).
Overview
Complete Zig 0.16.0+ bindings for the Brotli C library with 100% public C API coverage, providing idiomatic Zig types, error handling, allocator support, and memory management.
What's New
- Complete Zig 0.16.0+ bindings for Brotli
- 100% public C API coverage (30/30 functions)
- High-level, allocator-friendly Zig API
- One-shot and streaming compression/decompression
- Shared and prepared dictionary support
- Metadata block support
- Full encoder and decoder parameter coverage
- Strongly typed enums and comprehensive error handling
Features
| Feature | Description |
|---|---|
| One-shot API | compress, decompress, compressWithOptions, decompressWithOptions, decompressSimple |
| Streaming Encoder | Encoder.compressStream with process, flush, finish, and emit_metadata |
| Streaming Decoder | Decoder.decompressStream with byte tracking and automatic buffer management |
| Dictionaries | PreparedDictionary, SharedDictionary, encoder/decoder dictionary attachment |
| Metadata | Metadata emission and callback support |
| Custom Allocators | Works with any std.mem.Allocator |
| Large Window | Supports Brotli large window mode |
| Error Handling | Zig-native error mapping for all decoder error codes |
API Coverage
| Category | Coverage |
|---|---|
| Encoder | 15 functions |
| Decoder | 14 functions |
| Shared Dictionary | 3 functions |
| Total | 30/30 public C API functions |
Quality
- 124 automated tests
- 10 runnable examples
- Continuous Integration on Linux, macOS, and Windows
Quick Start
const brotli = @import("brotli");
// Simple compression
const compressed = try brotli.compress(allocator, input);
defer allocator.free(compressed);
const decompressed = try brotli.decompress(allocator, compressed);
defer allocator.free(decompressed);
// Compression with options
const custom = try brotli.compressWithOptions(allocator, input, .{
.quality = 6,
.lgwin = 18,
.mode = .text,
});
defer allocator.free(custom);Installation
zig fetch --save git+https://github.com/muhammad-fiaz/brotli.zig.git#0.0.1Compatibility
- Zig 0.16.0+
- Linux
- macOS
- Windows
Upstream
- Brotli C library (RFC 7932)
- Bundled Brotli source compiled directly via
build.zig
Authors
- Muhammad Fiaz — Zig bindings, build system, and API design
- Google Brotli Authors — Original Brotli compression library
License
MIT