Struct adblock::FilterSet

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

Manages a set of rules to be added to an crate::Engine.

To be able to efficiently handle special options like $badfilter, and to allow optimizations, all rules must be available when the Engine is first created. FilterSet allows assembling a compound list from multiple different sources before compiling the rules into an Engine.

Implementations§

source§

impl FilterSet

source

pub fn new(debug: bool) -> Self

Creates a new FilterSet. debug specifies whether or not to save information about the original raw filter rules alongside the more compact internal representation. If enabled, this information will be passed to the corresponding Engine.

source

pub fn add_filter_list( &mut self, filter_list: &str, opts: ParseOptions, ) -> FilterListMetadata

Adds the contents of an entire filter list to this FilterSet. Filters that cannot be parsed successfully are ignored. Returns any discovered metadata about the list of rules added.

source

pub fn add_filters( &mut self, filters: impl IntoIterator<Item = impl AsRef<str>>, opts: ParseOptions, ) -> FilterListMetadata

Adds a collection of filter rules to this FilterSet. Filters that cannot be parsed successfully are ignored. Returns any discovered metadata about the list of rules added.

source

pub fn add_filter( &mut self, filter: &str, opts: ParseOptions, ) -> Result<(), FilterParseError>

Adds the string representation of a single filter rule to this FilterSet.

Trait Implementations§

source§

impl Clone for FilterSet

source§

fn clone(&self) -> FilterSet

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 Default for FilterSet

source§

fn default() -> Self

Equivalent to FilterSet::new(false), or FilterSet::new(true) when compiled in test configuration.

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