Trait cssparser_color::ColorParser
source · pub trait ColorParser<'i> {
type Output: FromParsedColor;
type Error: 'i;
// Provided methods
fn parse_angle_or_number<'t>(
&self,
input: &mut Parser<'i, 't>
) -> Result<AngleOrNumber, ParseError<'i, Self::Error>> { ... }
fn parse_percentage<'t>(
&self,
input: &mut Parser<'i, 't>
) -> Result<f32, ParseError<'i, Self::Error>> { ... }
fn parse_number<'t>(
&self,
input: &mut Parser<'i, 't>
) -> Result<f32, ParseError<'i, Self::Error>> { ... }
fn parse_number_or_percentage<'t>(
&self,
input: &mut Parser<'i, 't>
) -> Result<NumberOrPercentage, ParseError<'i, Self::Error>> { ... }
}
Expand description
A trait that can be used to hook into how cssparser
parses color
components, with the intention of implementing more complicated behavior.
For example, this is used by Servo to support calc() in color.
Required Associated Types§
sourcetype Output: FromParsedColor
type Output: FromParsedColor
The type that the parser will construct on a successful parse.
Provided Methods§
sourcefn parse_angle_or_number<'t>(
&self,
input: &mut Parser<'i, 't>
) -> Result<AngleOrNumber, ParseError<'i, Self::Error>>
fn parse_angle_or_number<'t>( &self, input: &mut Parser<'i, 't> ) -> Result<AngleOrNumber, ParseError<'i, Self::Error>>
Parse an <angle>
or <number>
.
Returns the result in degrees.
sourcefn parse_percentage<'t>(
&self,
input: &mut Parser<'i, 't>
) -> Result<f32, ParseError<'i, Self::Error>>
fn parse_percentage<'t>( &self, input: &mut Parser<'i, 't> ) -> Result<f32, ParseError<'i, Self::Error>>
Parse a <percentage>
value.
Returns the result in a number from 0.0 to 1.0.
sourcefn parse_number<'t>(
&self,
input: &mut Parser<'i, 't>
) -> Result<f32, ParseError<'i, Self::Error>>
fn parse_number<'t>( &self, input: &mut Parser<'i, 't> ) -> Result<f32, ParseError<'i, Self::Error>>
Parse a <number>
value.
sourcefn parse_number_or_percentage<'t>(
&self,
input: &mut Parser<'i, 't>
) -> Result<NumberOrPercentage, ParseError<'i, Self::Error>>
fn parse_number_or_percentage<'t>( &self, input: &mut Parser<'i, 't> ) -> Result<NumberOrPercentage, ParseError<'i, Self::Error>>
Parse a <number>
value or a <percentage>
value.