compression-rs
Safe Rust bindings for Apple’s Compression and AppleArchive APIs on macOS.
compression-rs 0.2.0 uses a Swift bridge in front of the C-only Apple SDK
surfaces. The default API is safe Rust over opaque Swift-owned handles, while
the original compression.h FFI remains available behind the raw-ffi feature.
Requirements
- macOS
- Xcode / Swift toolchain available on
PATH(build.rsrunsswift build)
Installation
[]
= "0.2"
Enable raw compression.h bindings when needed:
[]
= { = "0.2", = ["raw-ffi"] }
Covered areas
CompressionStreamviaCompressionStream,Encoder, andDecoder- one-shot
CompressionEncode/CompressionDecodehelpers AAByteStreamfile, fd, temp-file, shared-buffer, compression, and random-access APIsAAArchiveStreamencode, decode, extract, convert, header, and blob APIsAAFieldKey/AAFieldKeySetAAHeader- requested
AAEntryStreamcoverage, mapped toPathList,EntryMessage, andEntryAttributes
See COVERAGE.md for the per-area SDK mapping and deferred surface.
Quick start
use ;
API notes
Algorithm::ALLcontains the stream-capable algorithms.Algorithm::BUFFER_ALLadditionally includes buffer-only algorithms such asLz4RawandLzbitmap.compress/decompressuse stream APIs when available and automatically fall back to repeated one-shot buffer calls for buffer-only algorithms.raw-fficurrently preserves the directcompression.hsurface. AppleArchive stays behind the Swift bridge.- AppleArchive does not define a concrete
AAEntryStreamtype; this crate uses the entry-levelAAPathList,AAEntryMessage, andAAEntryAttributesAPIs to cover that requested area.
Examples
This release also includes examples and tests for all requested logical areas:
01_roundtrip02_compression_encode_one_shot03_compression_decode_one_shot04_aa_archive_stream_roundtrip05_aa_byte_stream_pipeline06_aa_entry_stream_path_list07_aa_field_key_set08_aa_header_roundtrip
License
Licensed under either of:
- MIT license (LICENSE-MIT)
- Apache License, Version 2.0 (LICENSE-APACHE)