Struct Parser

Source
struct Parser<'a> {
    s: &'a str,
    ix: usize,
}

Fields§

§s: &'a str§ix: usize

Implementations§

Source§

impl<'a> Parser<'a>

Source

fn new(s: &'a str) -> Self

Source

fn consume_comments(&mut self) -> Result<(), ParseError>

Source

fn number(&mut self) -> Option<f64>

Source

fn ident(&mut self) -> Option<&'a str>

Source

fn ch(&mut self, ch: u8) -> bool

Source

fn raw_ch(&mut self, ch: u8) -> bool

Attempt to read the exact ASCII character given, returning whether that character was read.

The parser proceeds to the next character if the character was successfully read.

Source

fn ws_one(&mut self) -> bool

Source

fn ws(&mut self) -> bool

Source

fn value(&mut self) -> Option<Value<'a>>

Source

fn scaled_component( &mut self, scale: f64, pct_scale: f64, ) -> Result<Option<f64>, ParseError>

Parse a color component.

Source

fn angle(&mut self) -> Result<Option<f64>, ParseError>

Source

fn optional_comma(&mut self, comma: bool) -> Result<(), ParseError>

Source

fn rgb(&mut self) -> Result<DynamicColor, ParseError>

Source

fn alpha(&mut self, mode: Mode) -> Result<Option<f64>, ParseError>

Read a slash separator and an alpha value.

The value may be either number or a percentage.

The alpha value defaults to 1.0 if not present. The value will be clamped to the range [0, 1].

If the value is "none", then Ok(None) will be returned.

The separator will be a '/' in modern mode and a ',' in legacy mode. If no separator is present, then the default value will be returned.

Reference: § 4.2 of CSS Color 4 spec.

Source

fn lab( &mut self, lmax: f64, c: f64, tag: ColorSpaceTag, ) -> Result<DynamicColor, ParseError>

Source

fn lch( &mut self, lmax: f64, c: f64, tag: ColorSpaceTag, ) -> Result<DynamicColor, ParseError>

Source

fn hsl(&mut self) -> Result<DynamicColor, ParseError>

Source

fn hwb(&mut self) -> Result<DynamicColor, ParseError>

Source

fn color(&mut self) -> Result<DynamicColor, ParseError>

Trait Implementations§

Source§

impl<'a> Default for Parser<'a>

Source§

fn default() -> Parser<'a>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Parser<'a>

§

impl<'a> RefUnwindSafe for Parser<'a>

§

impl<'a> Send for Parser<'a>

§

impl<'a> Sync for Parser<'a>

§

impl<'a> Unpin for Parser<'a>

§

impl<'a> UnwindSafe for Parser<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.