Trait cssparser::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>,
    ) -> 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>, ) -> 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§