Struct pearl::filter::bloom::Bloom

source ·
pub struct Bloom { /* private fields */ }
Expand description

Bloom filter

Implementations§

source§

impl Bloom

source

pub fn new(config: Config) -> Self

Create new bloom filter

source

pub fn empty() -> Self

Creates empty bloom filter

source

pub fn checked_add_assign(&mut self, other: &Bloom) -> bool

Merge filters

source

pub fn clear(&mut self)

Set in-memory filter buffer to zeroed array

source

pub fn is_offloaded(&self) -> bool

Check if filter offloaded

source

pub fn offload_from_memory(&mut self) -> usize

Clear in-memory filter buffer

source

pub fn to_raw(&self) -> Result<Vec<u8>>

Serialize filter to bytes

source

pub fn from_raw(buf: &[u8]) -> Result<Self>

Deserialize filter from bytes

source

pub fn add(&self, item: impl AsRef<[u8]>) -> Result<()>

Add value to filter

source

pub fn contains_in_memory(&self, item: impl AsRef<[u8]>) -> Option<FilterResult>

Check filter in-memory (if not offloaded)

source

pub async fn contains_in_file<P: BloomDataProvider>( &self, provider: &P, item: impl AsRef<[u8]> ) -> Result<FilterResult>

Check filter by reading bits from file

source

pub fn memory_allocated(&self) -> usize

Get amount of memory allocated for filter

Trait Implementations§

source§

impl Clone for Bloom

source§

fn clone(&self) -> Self

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 Debug for Bloom

source§

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

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

impl<K> FilterTrait<K> for Bloomwhere K: AsRef<[u8]> + Sync + Send + Debug,

source§

fn add(&self, key: &K)

Add key to filter
source§

fn contains_fast(&self, key: &K) -> FilterResult

Check if key in filter (should be implemented if filter can be checked without waiting)
source§

fn contains<'life0, 'life1, 'life2, 'async_trait, P>( &'life0 self, provider: &'life1 P, key: &'life2 K ) -> Pin<Box<dyn Future<Output = FilterResult> + Send + 'async_trait>>where P: 'async_trait + BloomDataProvider, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Check if key in filter (can take some time)
source§

fn offload_filter(&mut self) -> usize

Offload filter from memory if possible
source§

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

Add another filter to this filter
source§

fn memory_allocated(&self) -> usize

Memory used by filter
source§

fn clear_filter(&mut self)

Clear all filter data
source§

fn is_filter_offloaded(&self) -> bool

Check if filter was offloaded

Auto Trait Implementations§

§

impl RefUnwindSafe for Bloom

§

impl Send for Bloom

§

impl Sync for Bloom

§

impl Unpin for Bloom

§

impl UnwindSafe for Bloom

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere 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 Twhere 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 Twhere 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.