rust-openzl (vendored)
Rust bindings for OpenZL with a vendored C library (git submodule at vendor/openzl).
OpenZL is a graph-based typed compression library optimized for structured data. Unlike generic compressors (zlib/zstd), OpenZL uses compression graphs to define how to compress specific data types.
- Always builds against the vendored source; no system or network dependencies.
openzl-sys: unsafe FFI + CMake build of the C library.openzl: safe, ergonomic API on top ofopenzl-sys.
Quick Start
Usage Examples
Serial Compression (Generic Data)
use ;
let data = b"Hello, OpenZL!";
let compressed = compress_serial?;
let decompressed = decompress_serial?;
assert_eq!;
Numeric Compression (Optimized for Arrays)
use ;
// Compress numeric arrays with specialized algorithms
let data: = .collect;
let compressed = compress_numeric?;
let decompressed: = decompress_numeric?;
assert_eq!;
// Works with all numeric types: u8, u16, u32, u64, i8, i16, i32, i64, f32, f64
Graph-Based Compression
use ;
// Use specific compression graphs for different data types
let data = b"Repeated data...".repeat;
// ZSTD graph for general-purpose compression
let compressed = compress_with_graph?;
// Store graph for no compression (testing/debugging)
let stored = compress_with_graph?;
Architecture
OpenZL is fundamentally a graph-based typed compression library:
- Compression Graphs define HOW to compress specific data structures
- Standard Graphs: ZSTD, NUMERIC, FIELD_LZ, STORE, ENTROPY, etc.
- TypedRef: Borrowed references to typed input data
- TypedBuffer: Owned decompression output buffers
This is NOT a drop-in replacement for zlib/zstd. Serial compression is just a compatibility shim.
Testing
# Run with output to see compression ratios
Regenerating Bindings
Bindings are automatically generated during the build process. To force regeneration after updating the OpenZL submodule:
The bindings configuration in openzl-sys/build.rs uses:
- Rust-style enums for type safety
- Allowlist for
ZL_*symbols only - Layout tests for ABI verification