BuilderWithBits

Struct BuilderWithBits 

Source
pub struct BuilderWithBits<S = DefaultHasher> { /* private fields */ }
Expand description

A Bloom filter builder with an immutable number of bits.

This type can be used to construct an instance of BloomFilter via the builder pattern.

§Examples

use fastbloom::BloomFilter;

let builder = BloomFilter::with_num_bits(1024);
let builder = BloomFilter::from_vec(vec![0; 8]);

Implementations§

Source§

impl BuilderWithBits

Source

pub fn seed(self, seed: &u128) -> Self

Sets the seed for this builder. The later constructed Bloom filter will use this seed when hashing items.

§Examples
use fastbloom::BloomFilter;

let bloom = BloomFilter::with_num_bits(1024).seed(&1).hashes(4);
Source§

impl<S: BuildHasher> BuilderWithBits<S>

Source

pub fn hasher<H: BuildHasher>(self, hasher: H) -> BuilderWithBits<H>

Sets the hasher for this builder. The later constructed Bloom filter will use this hasher when inserting and checking items.

§Examples
use fastbloom::BloomFilter;
use ahash::RandomState;

let bloom = BloomFilter::with_num_bits(1024).hasher(RandomState::default()).hashes(4);
Source

pub fn hashes(self, num_hashes: u32) -> BloomFilter<S>

“Consumes” this builder, using the provided num_hashes to return an empty BloomFilter.

§Examples
use fastbloom::BloomFilter;

let bloom = BloomFilter::with_num_bits(1024).hashes(4);
Source

pub fn expected_items(self, expected_num_items: usize) -> BloomFilter<S>

“Consumes” this builder, using the provided expected_num_items to return an empty BloomFilter. The number of hashes is optimized based on expected_num_items to maximize Bloom filter accuracy (minimize false positives chance on BloomFilter::contains). More or less than expected_num_items may be inserted into Bloom filter.

§Examples
use fastbloom::BloomFilter;

let bloom = BloomFilter::with_num_bits(1024).expected_items(500);
Source

pub fn items<I: IntoIterator<IntoIter = impl ExactSizeIterator<Item = impl Hash>>>( self, items: I, ) -> BloomFilter<S>

“Consumes” this builder and constructs a BloomFilter containing all values in items. The number of hashes per item is optimized based on items.len() to maximize Bloom filter accuracy (minimize false positives chance on BloomFilter::contains).

§Examples
use fastbloom::BloomFilter;

let bloom = BloomFilter::with_num_bits(1024).items([1, 2, 3]);

Trait Implementations§

Source§

impl<S: Clone> Clone for BuilderWithBits<S>

Source§

fn clone(&self) -> BuilderWithBits<S>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S: Debug> Debug for BuilderWithBits<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S: BuildHasher> PartialEq for BuilderWithBits<S>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S: BuildHasher> Eq for BuilderWithBits<S>

Auto Trait Implementations§

§

impl<S> Freeze for BuilderWithBits<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for BuilderWithBits<S>
where S: RefUnwindSafe,

§

impl<S> Send for BuilderWithBits<S>
where S: Send,

§

impl<S> Sync for BuilderWithBits<S>
where S: Sync,

§

impl<S> Unpin for BuilderWithBits<S>
where S: Unpin,

§

impl<S> UnwindSafe for BuilderWithBits<S>
where S: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V