pub struct BuilderWithFalsePositiveRate<const BLOCK_SIZE_BITS: usize = 512, S = DefaultHasher> { /* private fields */ }
Expand description

A bloom filter builder with an immutable false positive rate.

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

§Examples

use fastbloom::BloomFilter;

let builder = BloomFilter::with_false_pos(0.01);

Implementations§

source§

impl<const BLOCK_SIZE_BITS: usize> BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS>

source

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

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

§Examples
use fastbloom::BloomFilter;

let bloom = BloomFilter::with_false_pos(0.001).seed(&1).expected_items(100);
source§

impl<const BLOCK_SIZE_BITS: usize, S: BuildHasher> BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>

source

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

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

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

let bloom = BloomFilter::with_false_pos(0.001).hasher(RandomState::default()).expected_items(100);
source

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

“Consumes” this builder, using the provided expected_num_items to return an empty BloomFilter. The number of hashes and underlying memory is optimized based on expected_num_items to meet the desired false positive rate. More or less than expected_num_items may be inserted into BloomFilter.

§Examples
use fastbloom::BloomFilter;

let bloom = BloomFilter::with_false_pos(0.001).expected_items(500);
source

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

“Consumes” this builder and constructs a BloomFilter containing all values in items. Like BuilderWithFalsePositiveRate::expected_items, the number of hashes per item and underlying memory is optimized based on items.len() to meet the desired false positive rate.

§Examples
use fastbloom::BloomFilter;

let bloom = BloomFilter::with_false_pos(0.001).items([1, 2, 3]);
source§

impl<const BLOCK_SIZE_BITS: usize, S: BuildHasher> BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>

source

pub fn block_size_64(self) -> BuilderWithFalsePositiveRate<64, S>

Set the block size of the bloom filter to 64 bits. The underlying bit vector size will be rounded up to be a multiple of the block size.

§Example
use fastbloom::BloomFilter;
let builder = BloomFilter::with_false_pos(0.01).block_size_64();
source§

impl<const BLOCK_SIZE_BITS: usize, S: BuildHasher> BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>

source

pub fn block_size_128(self) -> BuilderWithFalsePositiveRate<128, S>

Set the block size of the bloom filter to 128 bits. The underlying bit vector size will be rounded up to be a multiple of the block size.

§Example
use fastbloom::BloomFilter;
let builder = BloomFilter::with_false_pos(0.01).block_size_128();
source§

impl<const BLOCK_SIZE_BITS: usize, S: BuildHasher> BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>

source

pub fn block_size_256(self) -> BuilderWithFalsePositiveRate<256, S>

Set the block size of the bloom filter to 256 bits. The underlying bit vector size will be rounded up to be a multiple of the block size.

§Example
use fastbloom::BloomFilter;
let builder = BloomFilter::with_false_pos(0.01).block_size_256();
source§

impl<const BLOCK_SIZE_BITS: usize, S: BuildHasher> BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>

source

pub fn block_size_512(self) -> BuilderWithFalsePositiveRate<512, S>

Set the block size of the bloom filter to 512 bits. The underlying bit vector size will be rounded up to be a multiple of the block size.

§Example
use fastbloom::BloomFilter;
let builder = BloomFilter::with_false_pos(0.01).block_size_512();

Trait Implementations§

source§

impl<const BLOCK_SIZE_BITS: usize, S: Clone> Clone for BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>

source§

fn clone(&self) -> BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>

Returns a copy 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<const BLOCK_SIZE_BITS: usize, S: Debug> Debug for BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>

source§

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

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

impl<const BLOCK_SIZE_BITS: usize, S: BuildHasher> PartialEq for BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<const BLOCK_SIZE_BITS: usize, S: BuildHasher> Eq for BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>

Auto Trait Implementations§

§

impl<const BLOCK_SIZE_BITS: usize, S> Freeze for BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>
where S: Freeze,

§

impl<const BLOCK_SIZE_BITS: usize, S> RefUnwindSafe for BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>
where S: RefUnwindSafe,

§

impl<const BLOCK_SIZE_BITS: usize, S> Send for BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>
where S: Send,

§

impl<const BLOCK_SIZE_BITS: usize, S> Sync for BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>
where S: Sync,

§

impl<const BLOCK_SIZE_BITS: usize, S> Unpin for BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, S>
where S: Unpin,

§

impl<const BLOCK_SIZE_BITS: usize, S> UnwindSafe for BuilderWithFalsePositiveRate<BLOCK_SIZE_BITS, 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> 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,

§

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

§

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

§

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