croaring
Rust wrapper for CRoaring, providing fast compressed roaring bitmaps for set operations.
Repository Health
Technical Analysis
Croaring is a Rust wrapper around CRoaring, the high-performance C/C++ implementation of Roaring bitmaps. Roaring bitmaps are compressed bitmaps that store large sets of integers compactly while keeping set operations like union, intersection, and difference extremely fast, and this crate exposes that power through a safe, idiomatic Rust API.
It provides Bitmap, 64-bit bitmaps, bitsets, and a treemap type, with support for run-optimization, fast bulk operations, serialization, and cardinality queries. The library binds to the battle-tested CRoaring core used across databases and analytics systems.
What You Get
- A
Bitmaptype for compressed 32-bit integer sets with fast set operations - 64-bit bitmap and treemap types for larger key spaces
- In-place and bulk operations like
and_inplace,or_inplace, andfast_or - Run-length optimization via
run_optimizefor dense ranges - Serialization and deserialization to portable binary formats
no_std/no_alloccapable feature gating with optional allocator integration
Common Use Cases
- Storing and intersecting large sets of document or row IDs in search and analytics engines
- Computing fast unions and intersections over integer sets
- Persisting compressed bitmaps to disk or across a network
- Reducing memory footprint for sparse or clustered integer sets
Under The Hood
Architecture - The workspace splits the safe Rust API (croaring) from the generated FFI bindings and vendored C core (croaring-sys). Within the croaring crate, types are organized by structure (bitmap, bitmap64, bitset, treemap) with cross-cutting serialization.rs, callback.rs, and rust_alloc modules, all re-exported through lib.rs. Tech Stack - Rust edition 2024 (MSRV 1.95) over the CRoaring C/C++ implementation, with optional allocator-api2 integration and feature gates for std, alloc, and no-alloc builds. Code Quality - The crate ships dedicated tests, benches, property-test regressions, and a fuzz target, reflecting strong correctness and performance discipline for an FFI wrapper. API Design - Method names mirror Roaring’s well-known operation set (add, contains, cardinality, and_inplace, fast_or) so users familiar with Roaring in other languages transfer knowledge directly, and the safe wrapper hides raw pointer management.