pub trait QualifiedRuleParser<'i> {
    type Prelude;
    type QualifiedRule;
    type Error: 'i;

    // Provided methods
    fn parse_prelude<'t>(
        &mut self,
        input: &mut Parser<'i, 't>
    ) -> Result<Self::Prelude, ParseError<'i, Self::Error>> { ... }
    fn parse_block<'t>(
        &mut self,
        prelude: Self::Prelude,
        start: &ParserState,
        input: &mut Parser<'i, 't>
    ) -> Result<Self::QualifiedRule, ParseError<'i, Self::Error>> { ... }
}
Expand description

A trait to provide various parsing of qualified rules.

For example, there could be different implementations for top-level qualified rules (i.e. style rules with Selectors as prelude) and for qualified rules inside @keyframes (keyframe rules with keyframe selectors as prelude).

Default implementations that reject all qualified rules are provided, so that impl QualifiedRuleParser<(), ()> for ... {} can be used for example for using RuleListParser to parse a rule list with only at-rules (such as inside @font-feature-values).

Required Associated Types§

source

type Prelude

The intermediate representation of a qualified rule prelude.

source

type QualifiedRule

The finished representation of a qualified rule.

source

type Error: 'i

The error type that is included in the ParseError value that can be returned.

Provided Methods§

source

fn parse_prelude<'t>( &mut self, input: &mut Parser<'i, 't> ) -> Result<Self::Prelude, ParseError<'i, Self::Error>>

Parse the prelude of a qualified rule. For style rules, this is as Selector list.

Return the representation of the prelude, or Err(()) to ignore the entire at-rule as invalid.

The prelude is the part before the { /* ... */ } block.

The given input is a “delimited” parser that ends where the prelude should end (before the next {).

source

fn parse_block<'t>( &mut self, prelude: Self::Prelude, start: &ParserState, input: &mut Parser<'i, 't> ) -> Result<Self::QualifiedRule, ParseError<'i, Self::Error>>

Parse the content of a { /* ... */ } block for the body of the qualified rule.

The location passed in is source location of the start of the prelude.

Return the finished representation of the qualified rule as returned by RuleListParser::next, or Err(()) to ignore the entire at-rule as invalid.

Implementors§