| Crates.io | bbse |
| lib.rs | bbse |
| version | 2.1.0 |
| created_at | 2025-05-16 19:54:46.89373+00 |
| updated_at | 2025-05-23 04:03:58.794283+00 |
| description | Backward Binary Search Encoding โ minimal and deterministic scheme for sorted domains |
| homepage | |
| repository | https://github.com/shurankain/bbse |
| max_upload_size | |
| id | 1676987 |
| size | 15,932 |
bbse encodes integer values as the path that binary search would take to find them in a known range.
The result is a prefix-free, compact, reversible, and range-aware representation โ
ideal for low-footprint use cases like compression, embedded indexing, and color deltas.
no_std compatible with allocuse bbse::{encode, decode};
let bits = encode(0, 256, 128); // Path to 128 in [0, 256)
let value = decode(0, 256, &bits);
assert_eq!(value, 128);
Each encoded value is just a binary search path โ ideal for use as a stack of values:
use bbse::{encode, BBSEStack};
let mut stack = BBSEStack::new();
for value in [0, 1, 2, 3, 4, 5, 6, 7] {
stack.push(encode(0, 8, value));
}
let decoded = stack.decode_all(0, 8);
assert_eq!(decoded, vec![0, 1, 2, 3, 4, 5, 6, 7]);
use bbse::{encode_from, decode};
let bits = encode_from(0, 16, 3, 4); // Use midpoint = 4 instead of center
let value = decode(0, 16, &bits);
assert_eq!(value, 3);
This project originated while designing a custom image codec for RGB delta compression. By encoding deltas using binary search paths instead of entropy coding, we achieved:
MSRV (Minimum Supported Rust Version) This crate requires Rust 1.78.0 or later.
[dependencies]
bbse = "2.1.0"
For embedded or no_std use:
[dependencies.bbse]
version = "2.1.0"
default-features = false
std (default): Enables printing and full integration with standard I/Ono_std: Disables std, uses alloc only โ ideal for embedded targetsBBSE is simple, elegant, and inspired by the structure of the data itself โ not statistics. No entropy. No overhead. Just binary logic.
MIT