Enum cssparser::Token [] [src]

pub enum Token<'a> {
    Ident(CowRcStr<'a>),
    AtKeyword(CowRcStr<'a>),
    Hash(CowRcStr<'a>),
    IDHash(CowRcStr<'a>),
    QuotedString(CowRcStr<'a>),
    UnquotedUrl(CowRcStr<'a>),
    Delim(char),
    Number {
        has_sign: bool,
        value: f32,
        int_value: Option<i32>,
    },
    Percentage {
        has_sign: bool,
        unit_value: f32,
        int_value: Option<i32>,
    },
    Dimension {
        has_sign: bool,
        value: f32,
        int_value: Option<i32>,
        unit: CowRcStr<'a>,
    },
    WhiteSpace(&'a str),
    Comment(&'a str),
    Colon,
    Semicolon,
    Comma,
    IncludeMatch,
    DashMatch,
    PrefixMatch,
    SuffixMatch,
    SubstringMatch,
    CDO,
    CDC,
    Function(CowRcStr<'a>),
    ParenthesisBlock,
    SquareBracketBlock,
    CurlyBracketBlock,
    BadUrl(CowRcStr<'a>),
    BadString(CowRcStr<'a>),
    CloseParenthesis,
    CloseSquareBracket,
    CloseCurlyBracket,
}

One of the pieces the CSS input is broken into.

Some components use Cow in order to borrow from the original input string and avoid allocating/copying when possible.

Variants

A <at-keyword-token>

The value does not include the @ marker.

A <hash-token> with the type flag set to "unrestricted"

The value does not include the # marker.

A <hash-token> with the type flag set to "id"

The value does not include the # marker.

A <string-token>

The value does not include the quotes.

A <url-token>

The value does not include the url( ) markers. Note that url( <string-token> ) is represented by a Function token.

A <delim-token>

Fields of Number

Whether the number had a + or - sign.

This is used is some cases like the micro syntax. (See the parse_nth function.)

The value as a float

If the origin source did not include a fractional part, the value as an integer.

Fields of Percentage

Whether the number had a + or - sign.

The value as a float, divided by 100 so that the nominal range is 0.0 to 1.0.

If the origin source did not include a fractional part, the value as an integer. It is not divided by 100.

Fields of Dimension

Whether the number had a + or - sign.

This is used is some cases like the micro syntax. (See the parse_nth function.)

The value as a float

If the origin source did not include a fractional part, the value as an integer.

The unit, e.g. "px" in 12px

A comment.

The CSS Syntax spec does not generate tokens for comments, But we do, because we can (borrowed &str makes it cheap).

The value does not include the /* */ markers.

A : <colon-token>

A ; <semicolon-token>

A , <comma-token>

A <!-- <CDO-token>

A <function-token>

The value (name) does not include the ( marker.

A <(-token>

A <[-token>

A <{-token>

A <bad-url-token>

This token always indicates a parse error.

A <bad-string-token>

This token always indicates a parse error.

A <)-token>

When obtained from one of the Parser::next* methods, this token is always unmatched and indicates a parse error.

A <]-token>

When obtained from one of the Parser::next* methods, this token is always unmatched and indicates a parse error.

A <}-token>

When obtained from one of the Parser::next* methods, this token is always unmatched and indicates a parse error.

Methods

impl<'a> Token<'a>
[src]

[src]

Return whether this token represents a parse error.

BadUrl and BadString are tokenizer-level parse errors.

CloseParenthesis, CloseSquareBracket, and CloseCurlyBracket are unmatched and therefore parse errors when returned by one of the Parser::next* methods.

impl<'a> Token<'a>
[src]

[src]

Categorize a token into a type that determines when /**/ needs to be inserted between two tokens when serialized next to each other without whitespace in between.

See the TokenSerializationType::needs_separator_when_before method.

Trait Implementations

impl<'a> PartialEq for Token<'a>
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl<'a> Debug for Token<'a>
[src]

[src]

Formats the value using the given formatter.

impl<'a> Clone for Token<'a>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<'a> ToCss for Token<'a>
[src]

[src]

Serialize self in CSS syntax, writing to dest.

[src]

Serialize self in CSS syntax and return a string. Read more