[][src]Struct adblock::engine::Engine

pub struct Engine {
    pub blocker: Blocker,
    // some fields omitted
}

Main adblocking engine that allows efficient querying of resources to block.

Fields

blocker: Blocker

Implementations

impl Engine[src]

pub fn new(optimize: bool) -> Self[src]

Creates a new adblocking Engine. Engines created without rules should generally only be used with deserialization.

  • optimize specifies whether or not to attempt to compress the internal representation by combining similar rules.

pub fn from_rules(rules: &[String], format: FilterFormat) -> Self[src]

Loads rules in a single format, enabling optimizations and discarding debug information.

pub fn from_rules_debug(rules: &[String], format: FilterFormat) -> Self[src]

Loads rules, enabling optimizations and including debug information.

pub fn from_rules_parametrised(
    filter_rules: &[String],
    format: FilterFormat,
    debug: bool,
    optimize: bool
) -> Self
[src]

pub fn from_filter_set(set: FilterSet, optimize: bool) -> Self[src]

Loads rules from the given FilterSet. It is recommended to use a FilterSet when adding rules from multiple sources.

pub fn serialize(&self) -> Result<Vec<u8>, BlockerError>[src]

Serializes the Engine into a binary format so that it can be quickly reloaded later.

pub fn deserialize(&mut self, serialized: &[u8]) -> Result<(), BlockerError>[src]

Deserialize the Engine from the binary format generated by Engine::serialize.

pub fn check_network_urls(
    &self,
    url: &str,
    source_url: &str,
    request_type: &str
) -> BlockerResult
[src]

Check if a request for a network resource from url, of type request_type, initiated by source_url, should be blocked.

pub fn check_network_urls_with_hostnames(
    &self,
    url: &str,
    hostname: &str,
    source_hostname: &str,
    request_type: &str,
    third_party_request: Option<bool>
) -> BlockerResult
[src]

pub fn check_network_urls_with_hostnames_subset(
    &self,
    url: &str,
    hostname: &str,
    source_hostname: &str,
    request_type: &str,
    third_party_request: Option<bool>,
    previously_matched_rule: bool,
    force_check_exceptions: bool
) -> BlockerResult
[src]

pub fn filter_exists(&self, filter: &str) -> bool[src]

Check if a given filter has been previously added to this Engine.

Note that only network filters are currently supported by this method.

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

Sets this engine's tags to be only the ones provided in tags.

Tags can be used to cheaply enable or disable network rules with a corresponding $tag option.

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

Sets this engine's tags to additionally include the ones provided in tags.

Tags can be used to cheaply enable or disable network rules with a corresponding $tag option.

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

Sets this engine's tags to no longer include the ones provided in tags.

Tags can be used to cheaply enable or disable network rules with a corresponding $tag option.

pub fn tag_exists(&self, tag: &str) -> bool[src]

Checks if a given tag exists in this engine.

Tags can be used to cheaply enable or disable network rules with a corresponding $tag option.

pub fn use_resources(&mut self, resources: &[Resource])[src]

Sets this engine's resources to be only the ones provided in resources.

pub fn add_resource(&mut self, resource: Resource)[src]

Sets this engine's resources to additionally include resource.

pub fn get_resource(&self, key: &str) -> Option<RedirectResource>[src]

Gets a previously added resource from the engine.

pub fn hidden_class_id_selectors(
    &self,
    classes: &[String],
    ids: &[String],
    exceptions: &HashSet<String>
) -> Vec<String>
[src]

If any of the provided CSS classes or ids could cause a certain generic CSS hide rule (i.e. { display: none !important; }) to be required, this method will return a list of CSS selectors corresponding to rules referencing those classes or ids, provided that the corresponding rules are not excepted.

exceptions should be passed directly from HostnameSpecificResources.

pub fn url_cosmetic_resources(&self, url: &str) -> UrlSpecificResources[src]

Returns a set of cosmetic filter resources required for a particular url. Once this has been called, all CSS ids and classes on a page should be passed to hidden_class_id_selectors to obtain any stylesheets consisting of generic rules (if the returned generichide value is false).

Trait Implementations

impl Default for Engine[src]

fn default() -> Self[src]

Equivalent to Engine::new(true).

Auto Trait Implementations

impl RefUnwindSafe for Engine

impl Send for Engine

impl Sync for Engine

impl Unpin for Engine

impl UnwindSafe for Engine

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.