Expand description
On-chain LZ4 compression for Solana programs.
densol provides a Compressor trait and a ready-to-use Lz4 implementation
that fits within the SBF VM’s 32 KB heap constraint. Pair it with
densol-derive to add transparent
compression to any Anchor account field with a single attribute.
§Quick start
Add to Cargo.toml:
densol = "0.1"ⓘ
use densol::Lz4 as Strategy;
use densol::Compress;
#[account]
#[derive(Compress)]
pub struct MyAccount {
#[compress]
pub data: Vec<u8>,
}
// generated:
// my_account.set_data(&raw_bytes)?; // compress + store
// let raw = my_account.get_data()?; // load + decompress§Features
| Feature | Default | Description |
|---|---|---|
lz4 | yes | Enables the Lz4 strategy via lz4_flex |
discriminant | yes | Prepends a 1-byte algorithm tag to compressed output |
derive | yes | Re-exports the #[derive(Compress)] macro |
std | no | Implements std::error::Error for CompressionError |
Structs§
- Lz4
- LZ4 compression strategy.
Enums§
Traits§
- Compressor
- Stateless compression strategy.
Derive Macros§
- Compress
- Derive
set_<field>/get_<field>helpers for fields marked#[compress].