Struct rust_cascade::Cascade
source · pub struct Cascade { /* private fields */ }
Expand description
A multi-layer cascading Bloom filter.
Implementations§
source§impl Cascade
impl Cascade
sourcepub fn from_bytes(bytes: Vec<u8>) -> Result<Option<Self>, CascadeError>
pub fn from_bytes(bytes: Vec<u8>) -> Result<Option<Self>, CascadeError>
from_bytes attempts to decode and return a multi-layer cascading Bloom filter.
Arguments
bytes
- The encoded representation of the Bloom filters in this cascade. Starts with 2
little endian bytes indicating the version. The current version is 2. The Python
filter-cascade project defines the formats, see
https://github.com/mozilla/filter-cascade/blob/v0.3.0/filtercascade/fileformats.py
May be of length 0, in which case None
is returned.
sourcepub fn to_bytes(&self) -> Result<Vec<u8>, CascadeError>
pub fn to_bytes(&self) -> Result<Vec<u8>, CascadeError>
to_bytes encodes a cascade in the version 2 format.
sourcepub fn has(&self, entry: Vec<u8>) -> bool
pub fn has(&self, entry: Vec<u8>) -> bool
has determines if the given sequence of bytes is in the cascade.
Arguments
entry
- The bytes to query
pub fn invert(&mut self)
sourcepub fn approximate_size_of(&self) -> usize
pub fn approximate_size_of(&self) -> usize
Determine the approximate amount of memory in bytes used by this Cascade. Because this implementation does not integrate with the allocator, it can’t get an accurate measurement of how much memory it uses. However, it can make a reasonable guess, assuming the sizes of the bloom filters are large enough to dominate the overall allocated size.