BloomFilterBuilder

Struct BloomFilterBuilder 

Source
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,

Source

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).

Source

pub fn with_bitmap<U>(self) -> BloomFilterBuilder<H, U>
where U: Bitmap,

Source

pub fn build<T: Hash>(self) -> Bloom2<H, B, T>

Initialise the Bloom2 instance with the provided parameters.

Source

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,

Source

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).

Source§

fn default() -> BloomFilterBuilder<RandomState, CompressedBitmap>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<H, B> Freeze for BloomFilterBuilder<H, B>
where H: Freeze, B: Freeze,

§

impl<H, B> RefUnwindSafe for BloomFilterBuilder<H, B>

§

impl<H, B> Send for BloomFilterBuilder<H, B>
where H: Send, B: Send,

§

impl<H, B> Sync for BloomFilterBuilder<H, B>
where H: Sync, B: Sync,

§

impl<H, B> Unpin for BloomFilterBuilder<H, B>
where H: Unpin, B: Unpin,

§

impl<H, B> UnwindSafe for BloomFilterBuilder<H, B>
where H: UnwindSafe, B: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.