Crate lerc

Source
Expand description

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

Structs§

BlobInfo
Metadata extracted from a LERC blob using lerc_getBlobInfo.

Enums§

LercError
Represents possible errors returned by LERC operations.

Traits§

LercDataType
Maps Rust types to LERC C API type codes.

Functions§

decode
Decodes a LERC-compressed byte buffer into typed raster values.
decode_auto
Decodes a LERC blob by first inspecting its metadata with get_blob_info.
decode_with_info
Decodes a LERC blob using the provided BlobInfo metadata.
encode
Encodes typed raster data into a LERC-compressed byte buffer.
get_blob_info
Parses metadata from a LERC-compressed blob without decoding the data.