compression-rs
Safe Rust bindings for Apple's libcompression APIs on macOS.
compression-rs covers the core pieces you typically need first:
- one-shot
compression_encode_buffer/compression_decode_buffer - streaming
Encoder/Decoderwrappers built oncompression_stream_* - algorithms:
LZ4,LZFSE,LZMA,zlib, andBrotli - ergonomic
compress/decompresshelpers that grow output buffers for you
Status
Initial 0.1.0 coverage focuses on the public compression.h surface that is
useful for in-memory tools and streaming pipelines.
Installation
[]
= "0.1"
Quick start
use ;
Highlights
- Direct wrappers for
compression_encode_bufferandcompression_decode_buffer - Safe
Encoder/Decoderstreaming types for chunked workloads - No Swift bridge required — this crate is pure Rust + C FFI
examples/01_roundtrip.rssmoke test for a 64 KiB LZFSE round-trip
API notes
compression_encode_bufferandcompression_decode_bufferexpect the caller to provide the destination buffer and return the number of bytes written.compressanddecompressbuild on the streaming APIs so they can resize output buffers automatically.Algorithm::Brotlirequires a macOS version that ships Brotli support inlibcompression.
Smoke example
Expected tail output:
✅ compression round-trip OK
License
Licensed under either of:
- MIT license (LICENSE-MIT)
- Apache License, Version 2.0 (LICENSE-APACHE)