Skip to main content

hashrope/
lib.rs

1//! # hashrope
2//!
3//! A BB[2/7] weight-balanced binary tree augmented with polynomial hash
4//! metadata at every node.
5//!
6//! Zero dependencies by default. `no_std + alloc` compatible, including
7//! the optional `bigint` feature for Python-compatible arbitrary precision.
8//! The default API uses bit-folding Mersenne modular reduction; the optional
9//! arbitrary-precision API uses `BigUint` modular arithmetic.
10//! Nodes are stored in a contiguous arena for cache-friendly access.
11
12#![no_std]
13extern crate alloc;
14
15/// The 127-bit Mersenne prime. Use the optional `bigint` module for hashing
16/// with this modulus; the existing `u64` API retains its 61-bit default.
17pub const MERSENNE_127: u128 = (1u128 << 127) - 1;
18
19pub mod polynomial_hash;
20pub mod rope;
21pub mod sliding;
22
23#[cfg(feature = "bigint")]
24pub mod bigint;
25
26pub use polynomial_hash::{mersenne_mod, mersenne_mul, phi, PolynomialHash, MERSENNE_61};
27pub use rope::{
28    rope_concat, rope_equal, rope_from_bytes, rope_hash, rope_height, rope_lcp, rope_len,
29    rope_range_equal, rope_range_lcp, rope_repeat, rope_split, rope_substr_hash, rope_to_bytes,
30    validate_rope, Arena, Node, NodeId, NodeInner, LAZY_SENTINEL,
31};
32pub use sliding::SlidingWindow;