Trait cssparser::DeclarationParser
[−]
[src]
pub trait DeclarationParser {
type Declaration;
fn parse_value(&mut self,
name: &str,
input: &mut Parser)
-> Result<Self::Declaration, ()>;
}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.
Associated Types
type Declaration
The finished representation of a declaration.
Required Methods
fn parse_value(&mut self,
name: &str,
input: &mut Parser)
-> Result<Self::Declaration, ()>
name: &str,
input: &mut Parser)
-> Result<Self::Declaration, ()>
Parse the value of a declaration with the given name.
Return the finished representation for the declaration
as returned by DeclarationListParser::next,
or 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_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.