Installation¶
Basic Setup¶
Add blockchain-compression to your Cargo.toml:
Feature Flags¶
The library uses feature flags to control which compression backends are compiled:
| Feature | Backend | Default | Description |
|---|---|---|---|
deflate |
DEFLATE (flate2) | Yes | General-purpose compression, widely compatible |
zstd |
Zstandard | No | Recommended for blockchain data -- best ratios |
lz4 |
LZ4 | No | Fastest compression/decompression speed |
Recommended: Zstandard¶
For blockchain data, use the zstd feature. It provides the best compression ratios with custom dictionary support:
Multiple Backends¶
You can enable multiple backends simultaneously:
Default Feature¶
The deflate feature is enabled by default. To use only zstd:
System Requirements¶
- Rust: 1.70+
- OS: Linux, macOS, Windows
- zstd feature: Requires a C compiler for
zstd-sys(automatically handled bycccrate)