cssparser

Trait DeclarationParser

Source
pub trait DeclarationParser<'i> {
    type Declaration;
    type Error: 'i;

    // Provided method
    fn parse_value<'t>(
        &mut self,
        name: CowRcStr<'i>,
        input: &mut Parser<'i, 't>,
        _declaration_start: &ParserState,
    ) -> Result<Self::Declaration, ParseError<'i, Self::Error>> { ... }
}
Expand description

A trait to provide various parsing of declaration values.

For example, there could be different implementations for property declarations in style rules and for descriptors in @font-face rules.

Required Associated Types§

Source

type Declaration

The finished representation of a declaration.

Source

type Error: 'i

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

Provided Methods§

Source

fn parse_value<'t>( &mut self, name: CowRcStr<'i>, input: &mut Parser<'i, 't>, _declaration_start: &ParserState, ) -> Result<Self::Declaration, ParseError<'i, Self::Error>>

Parse the value of a declaration with the given name.

Return the finished representation for the declaration as returned by DeclarationListParser::next, or an Err(..) to ignore the entire declaration as invalid.

Declaration name matching should be case-insensitive in the ASCII range. This can be done with std::ascii::Ascii::eq_ignore_ascii_case, or with the match_ignore_ascii_case! macro.

The given input is a “delimited” parser that ends wherever the declaration value should end. (In declaration lists, before the next semicolon or end of the current block.)

If !important can be used in a given context, input.try_parse(parse_important).is_ok() should be used at the end of the implementation of this method and the result should be part of the return value.

Implementors§

impl<'a, 'b, 'i> DeclarationParser<'i> for CounterStyleRuleParser<'a, 'b>

impl<'a, 'b, 'i> DeclarationParser<'i> for FontFaceRuleParser<'a, 'b>

impl<'a, 'b, 'i> DeclarationParser<'i> for PropertyDeclarationParser<'a, 'b, 'i>

impl<'a, 'b, 'i> DeclarationParser<'i> for PropertyRuleParser<'a, 'b>

impl<'a, 'b, 'i> DeclarationParser<'i> for KeyframeListParser<'a, 'b>

impl<'a, 'b, 'i, T> DeclarationParser<'i> for FFVDeclarationsParser<'a, 'b, T>
where T: Parse,

impl<'a, 'i> DeclarationParser<'i> for NestedRuleParser<'a, 'i>