pub struct BloomFilterBuilder<H, B>where
H: BuildHasher,
B: Bitmap,{ /* private fields */ }Expand description
Construct Bloom2 instances with varying parameters.
use std::collections::hash_map::RandomState;
use bloom2::{BloomFilterBuilder, FilterSize};
let mut filter = BloomFilterBuilder::hasher(RandomState::default())
.size(FilterSize::KeyBytes2)
.build();
filter.insert(&"success!");Implementations§
Source§impl<H, B> BloomFilterBuilder<H, B>where
H: BuildHasher,
B: Bitmap,
impl<H, B> BloomFilterBuilder<H, B>where
H: BuildHasher,
B: Bitmap,
Sourcepub fn with_bitmap_data(self, bitmap: B, key_size: FilterSize) -> Self
pub fn with_bitmap_data(self, bitmap: B, key_size: FilterSize) -> Self
Set the bit storage (bitmap) for the bloom filter.
§Panics
This method may panic if bitmap is too small to hold any value in the
range produced by the key size.
Providing a bitmap instance that is non-empty can be used to restore
the state of a Bloom2 instance (although using serde can achieve
this safely too).
pub fn with_bitmap<U>(self) -> BloomFilterBuilder<H, U>where
U: Bitmap,
Sourcepub fn build<T: Hash>(self) -> Bloom2<H, B, T>
pub fn build<T: Hash>(self) -> Bloom2<H, B, T>
Initialise the Bloom2 instance with the provided parameters.
Sourcepub fn size(self, size: FilterSize) -> Self
pub fn size(self, size: FilterSize) -> Self
Control the in-memory size and false-positive probability of the filter.
Setting the bitmap size replaces the current Bitmap instance with a
new CompressedBitmap of the appropriate size.
See FilterSize.
Source§impl<H> BloomFilterBuilder<H, CompressedBitmap>where
H: BuildHasher,
impl<H> BloomFilterBuilder<H, CompressedBitmap>where
H: BuildHasher,
Sourcepub fn hasher(hasher: H) -> Self
pub fn hasher(hasher: H) -> Self
Initialise a BloomFilterBuilder that unless changed, will construct a
Bloom2 instance using a 2 byte key and use the specified hasher.
Trait Implementations§
Source§impl Default for BloomFilterBuilder<RandomState, CompressedBitmap>
Initialise a BloomFilterBuilder that unless changed, will construct a
Bloom2 instance using a 2 byte key and use Rust’s DefaultHasher
(SipHash at the time of writing).
impl Default for BloomFilterBuilder<RandomState, CompressedBitmap>
Initialise a BloomFilterBuilder that unless changed, will construct a
Bloom2 instance using a 2 byte key and use Rust’s DefaultHasher
(SipHash at the time of writing).