pub trait Parse: Sized {
// Required method
fn parse<'i>(parser: &mut Parser<'i, '_>) -> Result<Self, ParseError<'i>>;
// Provided method
fn parse_str(s: &str) -> Result<Self, ParseError<'_>> { ... }
}
Expand description
Trait to parse values using cssparser::Parser
.
Required Methods§
sourcefn parse<'i>(parser: &mut Parser<'i, '_>) -> Result<Self, ParseError<'i>>
fn parse<'i>(parser: &mut Parser<'i, '_>) -> Result<Self, ParseError<'i>>
Parses a value out of the parser
.
All value types should implement this for composability.
Provided Methods§
sourcefn parse_str(s: &str) -> Result<Self, ParseError<'_>>
fn parse_str(s: &str) -> Result<Self, ParseError<'_>>
Convenience function to parse a value out of a &str
.
This is useful mostly for tests which want to avoid creating a
cssparser::Parser
by hand. Property types do not need to reimplement this.
Object Safety§
This trait is not object safe.
Implementations on Foreign Types§
source§impl Parse for bool
impl Parse for bool
fn parse<'i>(parser: &mut Parser<'i, '_>) -> Result<Self, ParseError<'i>>
source§impl Parse for f64
impl Parse for f64
fn parse<'i>(parser: &mut Parser<'i, '_>) -> Result<Self, ParseError<'i>>
source§impl Parse for i32
impl Parse for i32
source§fn parse<'i>(parser: &mut Parser<'i, '_>) -> Result<Self, ParseError<'i>>
fn parse<'i>(parser: &mut Parser<'i, '_>) -> Result<Self, ParseError<'i>>
CSS integer
SVG1.1: https://www.w3.org/TR/SVG11/types.html#DataTypeInteger