Struct adblock::blocker::Blocker

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

Stores network filters for efficient querying.

Implementations§

source§

impl Blocker

source

pub fn check( &self, request: &Request, resources: &ResourceStorage, ) -> BlockerResult

Decide if a network request (usually from WebRequest API) should be blocked, redirected or allowed.

source

pub fn check_generic_hide(&self, hostname_request: &Request) -> bool

source

pub fn check_parameterised( &self, request: &Request, resources: &ResourceStorage, matched_rule: bool, force_check_exceptions: bool, ) -> BlockerResult

source

pub fn get_csp_directives(&self, request: &Request) -> Option<String>

Given a “main_frame” or “subdocument” request, check if some content security policies should be injected in the page.

source

pub fn new( network_filters: Vec<NetworkFilter>, options: &BlockerOptions, ) -> Blocker

source

pub fn optimize(&mut self)

If optimizations are enabled, the Blocker will be configured to automatically optimize its filters after batch updates. However, even if they are disabled, it is possible to manually call optimize(). It may be useful to have finer-grained control over optimization scheduling when frequently updating filters.

source

pub fn filter_exists(&self, filter: &NetworkFilter) -> bool

Has this exact filter already been added? Note that this is a best-effort method and may miss some filters, especially if optimizations are enabled.

source

pub fn add_filter(&mut self, filter: NetworkFilter) -> Result<(), BlockerError>

Add a single filter to this Blocker.

Filter optimization is skipped when using this method.

source

pub fn use_tags(&mut self, tags: &[&str])

source

pub fn enable_tags(&mut self, tags: &[&str])

source

pub fn disable_tags(&mut self, tags: &[&str])

source

pub fn tags_enabled(&self) -> Vec<String>

source

pub fn set_regex_discard_policy( &self, new_discard_policy: RegexManagerDiscardPolicy, )

Auto Trait Implementations§

§

impl !Freeze for Blocker

§

impl !RefUnwindSafe for Blocker

§

impl !Send for Blocker

§

impl !Sync for Blocker

§

impl Unpin for Blocker

§

impl !UnwindSafe for Blocker

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