pub trait DeclarationParser<'i> {
type Declaration;
type Error;
// Provided method
fn parse_value(
&mut self,
_name: CowRcStr<'i>,
_input: &mut Parser<'i>,
_declaration_start: &ParserState,
) -> Result<Self::Declaration, ParseError<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§
Sourcetype Declaration
type Declaration
The finished representation of a declaration.
Provided Methods§
Sourcefn parse_value(
&mut self,
_name: CowRcStr<'i>,
_input: &mut Parser<'i>,
_declaration_start: &ParserState,
) -> Result<Self::Declaration, ParseError<Self::Error>>
fn parse_value( &mut self, _name: CowRcStr<'i>, _input: &mut Parser<'i>, _declaration_start: &ParserState, ) -> Result<Self::Declaration, ParseError<Self::Error>>
Parse the value of a declaration with the given name.
Return the finished representation for the declaration
as returned by RuleBodyParser::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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".