#[non_exhaustive]pub enum Token {
Show 25 variants
Ident(String),
Function(String),
AtKeyword(String),
Hash {
value: String,
type_flag: HashType,
},
String(String),
BadString,
Url(String),
BadUrl,
Delim(char),
Number {
value: f64,
type_flag: NumericType,
},
Percentage {
value: f64,
},
Dimension {
value: f64,
type_flag: NumericType,
unit: String,
},
Whitespace,
Cdo,
Cdc,
Colon,
Semicolon,
Comma,
OpenSquare,
CloseSquare,
OpenParen,
CloseParen,
OpenCurly,
CloseCurly,
Eof,
}Expand description
A single CSS token, per spec §4.3.1 (“Consume a token”) and the token types defined at the start of §4.3.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Ident(String)
An identifier, e.g. screen.
Function(String)
An identifier immediately followed by (, e.g. calc(. The
( itself is consumed but not part of the stored string.
AtKeyword(String)
@ followed by an ident sequence, e.g. @media.
Hash
# followed by an ident-code-point/escape sequence, e.g. #foo.
Fields
String(String)
A quoted string, e.g. "screen".
BadString
A string that was not terminated correctly (e.g. an unescaped newline before the closing quote).
Url(String)
A url(...) token with an unquoted value.
BadUrl
A url(...) construct that could not be tokenized as a valid
URL token (e.g. an unescaped space in the unquoted value).
Delim(char)
A single code point that didn’t start any other token, e.g. ^.
Number
A numeric literal with no unit or % suffix, e.g. 42.
Fields
type_flag: NumericTypeWhether the literal had a fractional part/exponent.
Percentage
A numeric literal followed by %, e.g. 50%.
Dimension
A numeric literal followed by a unit, e.g. 10px.
Fields
type_flag: NumericTypeWhether the literal had a fractional part/exponent.
Whitespace
One or more consecutive whitespace code points.
Cdo
<!--
Cdc
-->
Colon
:
Semicolon
;
Comma
,
OpenSquare
[
CloseSquare
]
OpenParen
(
CloseParen
)
OpenCurly
{
CloseCurly
}
Eof
The end of the input stream. Always the last token produced by
Tokenizer, never followed by another token.