generic_bloom/lib.rs
1// This file is part of generic-bloom.
2//
3// generic-bloom is free software: you can redistribute it and/or
4// modify it under the terms of the GNU Affero General Public License
5// as published by the Free Software Foundation, either version 3 of
6// the License, or (at your option) any later version.
7//
8// generic-bloom is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Affero General Public License for more details. You should have
12// received a copy of the GNU Affero General Public License along with
13// generic-bloom. If not, see <https://www.gnu.org/licenses/>.
14
15//! This crate provides a [`BloomFilter`] trait which can be
16//! parameterized by different types of storage (via the [`BloomSet`]
17//! trait) to obtain traditional binary Bloom filters, counting Bloom
18//! filters, and spectral Bloom filters. For basic usage, see the
19//! documentation for [`SimpleBloomFilter`].
20//!
21//! [`BloomSet`] implementations are provided for
22//! [`BitBox`](bitvec::boxed::BitBox)es (for traditional bitmap-style
23//! Bloom filters) and `Box<[T]>` where `T` is a numeric type (for
24//! counting or spectral Bloom filters).
25//!
26//! # Example
27//! Basic usage:
28//! ```
29//! use generic_bloom::{BloomFilter, SimpleBloomFilter};
30//! use bitvec::prelude::*;
31//!
32//! let mut filter: SimpleBloomFilter<BitBox<usize, Lsb0>> = SimpleBloomFilter::new(10, 20);
33//! filter.insert(&48);
34//! filter.insert(&32);
35//! assert!(filter.contains(&48));
36//! assert!(filter.contains(&32));
37//! // May fail if 39 happens to be a false positive
38//! assert!(!filter.contains(&39));
39//! ```
40mod simple_filter;
41pub use simple_filter::SimpleBloomFilter;
42
43pub mod traits;
44pub use traits::filter::*;
45pub use traits::set::BloomSet;
46
47// #[cfg(test)]
48// mod tests {
49// use crate::*;
50// use bitvec::boxed::BitBox;
51// use bitvec::order::Lsb0;
52// }