pub enum CompositeFilter {
Byte(ByteFilter),
Ngram(NgramFilter),
Combine {
left: Box<CompositeFilter>,
right: Box<CompositeFilter>,
op: FilterOp,
},
}Expand description
A composite filter that combines byte and n-gram filters with logical operators.
§Example
use flashsieve::{ByteFilter, NgramFilter};
use flashsieve::filter::{CompositeFilter, FilterOp};
let a = ByteFilter::from_patterns(&[b"secret".as_slice()]);
let b = ByteFilter::from_patterns(&[b"token".as_slice()]);
let combined = CompositeFilter::combine_byte(a, b, FilterOp::Or);Variants§
Byte(ByteFilter)
A leaf byte filter.
Ngram(NgramFilter)
A leaf n-gram filter.
Combine
Logical combination of two composite filters.
Implementations§
Source§impl CompositeFilter
impl CompositeFilter
Sourcepub fn combine_byte(a: ByteFilter, b: ByteFilter, op: FilterOp) -> Self
pub fn combine_byte(a: ByteFilter, b: ByteFilter, op: FilterOp) -> Self
Combine two byte filters under a logical operator.
§Example
use flashsieve::{ByteFilter, filter::{CompositeFilter, FilterOp}};
let a = ByteFilter::from_patterns(&[b"secret".as_slice()]);
let b = ByteFilter::from_patterns(&[b"token".as_slice()]);
let combined = CompositeFilter::combine_byte(a, b, FilterOp::Or);Sourcepub fn combine_ngram(a: NgramFilter, b: NgramFilter, op: FilterOp) -> Self
pub fn combine_ngram(a: NgramFilter, b: NgramFilter, op: FilterOp) -> Self
Combine two ngram filters under a logical operator.
§Example
use flashsieve::{NgramFilter, filter::{CompositeFilter, FilterOp}};
let a = NgramFilter::from_patterns(&[b"secret".as_slice()]);
let b = NgramFilter::from_patterns(&[b"token".as_slice()]);
let combined = CompositeFilter::combine_ngram(a, b, FilterOp::Or);Sourcepub fn combine(a: Self, b: Self, op: FilterOp) -> Self
pub fn combine(a: Self, b: Self, op: FilterOp) -> Self
Combine two composite filters under an arbitrary logical operator.
§Example
use flashsieve::{ByteFilter, filter::{CompositeFilter, FilterOp}};
let left = CompositeFilter::Byte(ByteFilter::from_patterns(&[b"a".as_slice()]));
let right = CompositeFilter::Byte(ByteFilter::from_patterns(&[b"b".as_slice()]));
let combined = CompositeFilter::combine(left, right, FilterOp::And);Sourcepub fn matches(&self, histogram: &ByteHistogram, bloom: &NgramBloom) -> bool
pub fn matches(&self, histogram: &ByteHistogram, bloom: &NgramBloom) -> bool
Evaluate against a histogram and bloom pair.
§Example
use flashsieve::{ByteFilter, NgramBloom, filter::{CompositeFilter, FilterOp}};
let filter = CompositeFilter::Byte(ByteFilter::from_patterns(&[b"ab".as_slice()]));
let hist = flashsieve::ByteHistogram::from_block(b"ab");
let bloom = NgramBloom::from_block(b"ab", 1024).unwrap();
assert!(filter.matches(&hist, &bloom));Trait Implementations§
Source§impl Clone for CompositeFilter
impl Clone for CompositeFilter
Source§fn clone(&self) -> CompositeFilter
fn clone(&self) -> CompositeFilter
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CompositeFilter
impl RefUnwindSafe for CompositeFilter
impl Send for CompositeFilter
impl Sync for CompositeFilter
impl Unpin for CompositeFilter
impl UnsafeUnpin for CompositeFilter
impl UnwindSafe for CompositeFilter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more