[−][src]Struct adblock::Engine
The main object featured in this library. This object holds the adblocker's state, and can be queried to see if a given request should be blocked or not.
Request types
A few of Engine's methods have a field specifying a "resource type",
valid examples are:
beaconcsp_reportdocumentfontmediaobjectscriptstylesheet- and et cetera... See the Mozilla Web Documentation for more info.
Implementations
impl Engine[src]
pub fn new(filter_set: FilterSet, optimize: bool) -> Self[src]
Create a new adblocking engine
pub fn check_network_urls(
&self,
url: &str,
source_url: &str,
request_type: &str
) -> BlockerResult[src]
&self,
url: &str,
source_url: &str,
request_type: &str
) -> BlockerResult
Check if the given url—pointing to a resource of type request_type—
is blocked, assuming the request is made from the given source_url.
Returns an object of type BlockerResult.
Arguments
url- The URL of the request to checksource_url- The URL from where the request is maderequest_type- The resource type that the request points to
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]
&self,
url: &str,
hostname: &str,
source_hostname: &str,
request_type: &str,
third_party_request: Option<bool>
) -> BlockerResult
Check if a request should be blocked based on the given parameters.
Arguments
url- The URL of the request to checkhostname- The givenurl's hostnamesource_hostname- The hostname of the source URL.request_type- The resource type that the request points tothird_party_request- Is the given request to a third-party? Here,Nonecan be given and the engine will figure it out based on thehostnameandsource_hostname.
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]
&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
Check if a request should be blocked based on the given parameters.
Arguments
url- The URL of the request to checkhostname- The givenurl's hostnamesource_hostname- The hostname of the source URL.request_type- The resource type that the request points tothird_party_request- Is the given request to a third-party? Here,Nonecan be given and the engine will figure it out based on thehostnameandsource_hostname.previously_matched_rule- Return a match as long as there are no exceptionsforce_check_exceptions- Check exceptions even if no other rule matches
pub fn serialize<'p>(&mut self, py: Python<'p>) -> PyResult<&'p PyBytes>[src]
Serialize this blocking engine to bytes. They can then be deserialized
using deserialize() to get the same engine again.
pub fn serialize_to_file(&mut self, file: &str) -> PyResult<()>[src]
Serialize this blocking engine to a file. The file can then be
deserialized using deserialize_from_file() to get the same engine
again.
pub fn deserialize(&mut self, serialized: &[u8]) -> PyResult<()>[src]
Deserialize a blocking engine from bytes produced with serialize().
pub fn deserialize_from_file(&mut self, file: &str) -> PyResult<()>[src]
Deserialize a blocking engine from file produced with
serialize_to_file().
pub fn filter_exists(&self, filter: &str) -> bool[src]
Checks if the given filter exists in the blocking engine.
pub fn use_tags(&mut self, tags: Vec<&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: Vec<&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: Vec<&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 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.
pub fn hidden_class_id_selectors(
&self,
classes: Vec<String>,
ids: Vec<String>,
exceptions: HashSet<String>
) -> PyResult<Vec<String>>[src]
&self,
classes: Vec<String>,
ids: Vec<String>,
exceptions: HashSet<String>
) -> PyResult<Vec<String>>
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 UrlSpecificResources.
Trait Implementations
impl<'a> ExtractExt<'a> for &'a Engine[src]
impl<'a> ExtractExt<'a> for &'a mut Engine[src]
impl HasMethodsInventory for Engine[src]
type Methods = Pyo3MethodsInventoryForEngine
impl HasProtoRegistry for Engine[src]
impl IntoPy<PyObject> for Engine[src]
impl PyClass for Engine[src]
type Dict = PyClassDummySlot
Specify this class has #[pyclass(dict)] or not.
type WeakRef = PyClassDummySlot
Specify this class has #[pyclass(weakref)] or not.
type BaseNativeType = PyAny
The closest native ancestor. This is PyAny by default, and when you declare
#[pyclass(extends=PyDict)], it's PyDict. Read more
impl PyClassAlloc for Engine[src]
unsafe fn new(py: Python<'_>, subtype: *mut PyTypeObject) -> *mut Self::Layout[src]
unsafe fn dealloc(py: Python<'_>, self_: *mut Self::Layout)[src]
impl PyClassSend for Engine[src]
type ThreadChecker = ThreadCheckerStub<Engine>
impl PyTypeInfo for Engine[src]
type Type = Engine
Type of objects to store in PyObject struct
type BaseType = PyAny
Base class
type Layout = PyCell<Self>
Layout
type BaseLayout = PyCellBase<PyAny>
Layout of Basetype.
type Initializer = PyClassInitializer<Self>
Initializer for layout
type AsRefTarget = PyCell<Self>
Utility type to make AsPyRef work
const NAME: &'static str[src]
const MODULE: Option<&'static str>[src]
const DESCRIPTION: &'static str[src]
const FLAGS: usize[src]
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject[src]
fn is_instance(object: &PyAny) -> bool[src]
fn is_exact_instance(object: &PyAny) -> bool[src]
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T> FromPy<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> IntoPy<U> for T where
U: FromPy<T>, [src]
U: FromPy<T>,
impl<T> PyClassAlloc for T where
T: PyTypeInfo + PyClassWithFreeList, [src]
T: PyTypeInfo + PyClassWithFreeList,
unsafe fn new(
py: Python<'_>,
subtype: *mut PyTypeObject
) -> *mut <T as PyTypeInfo>::Layout[src]
py: Python<'_>,
subtype: *mut PyTypeObject
) -> *mut <T as PyTypeInfo>::Layout
unsafe fn dealloc(py: Python<'_>, self_: *mut <T as PyTypeInfo>::Layout)[src]
impl<T> PyMethods for T where
T: HasMethodsInventory, [src]
T: HasMethodsInventory,
fn py_methods() -> Vec<&'static PyMethodDefType>[src]
impl<T> PyProtoMethods for T where
T: HasProtoRegistry, [src]
T: HasProtoRegistry,
fn async_methods() -> Option<NonNull<PyAsyncMethods>>[src]
fn basic_methods() -> Option<NonNull<PyObjectMethods>>[src]
fn buffer_methods() -> Option<NonNull<PyBufferProcs>>[src]
fn descr_methods() -> Option<NonNull<PyDescrMethods>>[src]
fn gc_methods() -> Option<NonNull<PyGCMethods>>[src]
fn mapping_methods() -> Option<NonNull<PyMappingMethods>>[src]
fn number_methods() -> Option<NonNull<PyNumberMethods>>[src]
fn iter_methods() -> Option<NonNull<PyIterMethods>>[src]
fn sequence_methods() -> Option<NonNull<PySequenceMethods>>[src]
impl<T> PyTypeObject for T where
T: PyTypeInfo, [src]
T: PyTypeInfo,
fn type_object(py: Python<'_>) -> &PyType[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,