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§
sourcetype QualifiedRule
type QualifiedRule
The finished representation of a qualified rule.
Provided Methods§
sourcefn parse_prelude<'t>(
&mut self,
input: &mut Parser<'i, 't>,
) -> Result<Self::Prelude, ParseError<'i, Self::Error>>
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 an 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 {
).
sourcefn parse_block<'t>(
&mut self,
prelude: Self::Prelude,
start: &ParserState,
input: &mut Parser<'i, 't>,
) -> Result<Self::QualifiedRule, 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>>
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 an Err(..)
to ignore the entire at-rule as invalid.