2 unstable releases
Uses new Rust 2024
new 0.2.0 | Apr 25, 2025 |
---|---|
0.1.0 | Apr 22, 2025 |
#306 in Compression
76 downloads per month
16KB
262 lines
lerc
Safe and idiomatic Rust wrapper for Esri's LERC raster compression library.
Provides encoding, decoding, and metadata access for multi-band and multi-dimensional raster data with optional validity masks.
Built on top of lerc-sys
, with vendored LERC C++ source by default. Supports dynamic linking with --no-default-features
.
License
MIT OR Apache-2.0
lib.rs
:
Safe and idiomatic Rust wrapper for the Esri LERC compression library.
This crate provides high-level Rust bindings over the lerc-sys
crate, which links to the native LERC C++ library.
It supports encoding and decoding 2D, 3D, and multi-band raster data with optional pixel validity masks.
Features
- Safe, generic encoding and decoding using type parameters (
u8
,f32
,f64
, etc.) - Optional validity mask support
- Access to LERC blob metadata without full decompression
- Rich error handling with specific LERC error codes
Example: Encode
use lerc::encode;
let width = 256;
let height = 256;
let data = vec![0.0f32; width * height];
let compressed = encode(&data, None, width, height, 1, 1, 1, 0.001).unwrap();
Example: Decode
use lerc::{decode, get_blob_info};
let compressed: Vec<u8> = /* read from file or network */ vec![];
let info = get_blob_info(&compressed).unwrap();
let (data, mask) = decode::<f32>(&compressed, info.width, info.height, info.depth, info.bands, info.masks).unwrap();
Minimum Supported Rust Version
- Rust 1.60+ (due to
bindgen
and FFI support)
See also
- Esri LERC GitHub
lerc-sys
crate: low-level raw bindings
Dependencies
~5–7MB
~53K SLoC