[][src]Struct adblock::filters::cosmetic::CosmeticFilter

pub struct CosmeticFilter {
    pub entities: Option<Vec<Hash>>,
    pub hostnames: Option<Vec<Hash>>,
    pub mask: CosmeticFilterMask,
    pub not_entities: Option<Vec<Hash>>,
    pub not_hostnames: Option<Vec<Hash>>,
    pub raw_line: Option<String>,
    pub selector: String,
    pub key: Option<String>,
    pub style: Option<String>,
}

Struct representing a parsed cosmetic filter rule.

Fields

entities: Option<Vec<Hash>>hostnames: Option<Vec<Hash>>mask: CosmeticFilterMasknot_entities: Option<Vec<Hash>>not_hostnames: Option<Vec<Hash>>raw_line: Option<String>selector: Stringkey: Option<String>style: Option<String>

Implementations

impl CosmeticFilter[src]

pub fn locations_before_sharp(
    line: &str,
    sharp_index: usize
) -> impl Iterator<Item = (CosmeticFilterLocationType, &str)>
[src]

pub fn parse(
    line: &str,
    debug: bool
) -> Result<CosmeticFilter, CosmeticFilterError>
[src]

Parse the rule in line into a CosmeticFilter. If debug is true, the original rule will be reported in the resulting CosmeticFilter struct as well.

pub fn has_hostname_constraint(&self) -> bool[src]

Any cosmetic filter rule that specifies (possibly negated) hostnames or entities has a hostname constraint.

pub fn hidden_generic_rule(&self) -> Option<CosmeticFilter>[src]

In general, adding a hostname or entity to a rule increases the number of situations in which it applies. However, if a specific rule only has negated hostnames or entities, it technically should apply to any hostname which does not match a negation.

See: https://github.com/chrisaljoudi/uBlock/issues/145

To account for this inconsistency, this method will generate and return the corresponding 'hidden' generic rule if one applies.

Note that this behavior is not applied to script injections or custom style rules.

Trait Implementations

impl Clone for CosmeticFilter[src]

impl Debug for CosmeticFilter[src]

impl<'de> Deserialize<'de> for CosmeticFilter[src]

impl<'_> From<&'_ CosmeticFilter> for SpecificFilterType[src]

This implementation assumes the given rule has hostname or entity constraints, and that the appropriate 'hidden' generic rule has already been applied externally if necessary.

impl From<CosmeticFilter> for ParsedFilter[src]

impl Serialize for CosmeticFilter[src]

Auto Trait Implementations

impl RefUnwindSafe for CosmeticFilter

impl Send for CosmeticFilter

impl Sync for CosmeticFilter

impl Unpin for CosmeticFilter

impl UnwindSafe for CosmeticFilter

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> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

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

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.