Skip to main content

CompositeFilter

Enum CompositeFilter 

Source
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.

Fields

§left: Box<CompositeFilter>

Left operand.

§right: Box<CompositeFilter>

Right operand.

§op: FilterOp

The logical operator.

Implementations§

Source§

impl CompositeFilter

Source

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);
Source

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);
Source

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);
Source

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

Source§

fn clone(&self) -> CompositeFilter

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

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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.