Struct lol_html::Selector[][src]

pub struct Selector(_);

Parsed CSS selector.

Parsed selector can be used for different element content handlers without a necessity to re-parse CSS selector string for each of them.

Example

The structure implements the FromStr trait, so it can be constructed through str’s parse method.

use lol_html::Selector;

let selector: Selector = "#foo".parse().unwrap();

Supported selector

Currently the rewriter supports the following CSS selectors:

PatternRepresents
*any element
Eany element of type E
E:nth-child(n)an E element, the n-th child of its parent
E:first-childan E element, first child of its parent
E:nth-of-type(n)an E element, the n-th sibling of its type
E:first-of-typean E element, first sibling of its type
E:not(s)an E element that does not match either compound selector s
E.warningan E element belonging to the class warning
E#myidan E element with ID equal to "myid".
E[foo]an E element with a foo attribute
E[foo="bar"]an E element whose foo attribute value is exactly equal to "bar"
E[foo="bar" i]an E element whose foo attribute value is exactly equal to any (ASCII-range) case-permutation of "bar"
E[foo="bar" s]an E element whose foo attribute value is exactly and case-sensitively equal to "bar"
E[foo~="bar"]an E element whose foo attribute value is a list of whitespace-separated values, one of which is exactly equal to "bar"
E[foo^="bar"]an E element whose foo attribute value begins exactly with the string "bar"
E[foo$="bar"]an E element whose foo attribute value ends exactly with the string "bar"
E[foo*="bar"]an E element whose foo attribute value contains the substring "bar"
E[foo|=“en”]an E element whose foo attribute value is a hyphen-separated list of values beginning with "en"
E Fan F element descendant of an E element
E > Fan F element child of an E element

Trait Implementations

impl Clone for Selector[src]

impl Debug for Selector[src]

impl FromStr for Selector[src]

type Err = SelectorError

The associated error which can be returned from parsing.

Auto Trait Implementations

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