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
Ident(CowRcStr<'a>)AtKeyword(CowRcStr<'a>)The value does not include the @ marker.
Hash(CowRcStr<'a>)A <hash-token> with the type flag set to "unrestricted"
The value does not include the # marker.
IDHash(CowRcStr<'a>)A <hash-token> with the type flag set to "id"
The value does not include the # marker.
QuotedString(CowRcStr<'a>)The value does not include the quotes.
UnquotedUrl(CowRcStr<'a>)The value does not include the url( ) markers. Note that url( <string-token> ) is represented by a
Function token.
Delim(char)A <delim-token>
NumberFields of Number
has_sign: bool | Whether the number had a This is used is some cases like the <An+B> micro syntax. (See the |
value: f32 | The value as a float |
int_value: Option<i32> | If the origin source did not include a fractional part, the value as an integer. |
PercentageFields of Percentage
has_sign: bool | Whether the number had a |
unit_value: f32 | The value as a float, divided by 100 so that the nominal range is 0.0 to 1.0. |
int_value: Option<i32> | If the origin source did not include a fractional part, the value as an integer. It is not divided by 100. |
DimensionFields of Dimension
has_sign: bool | Whether the number had a This is used is some cases like the <An+B> micro syntax. (See the |
value: f32 | The value as a float |
int_value: Option<i32> | If the origin source did not include a fractional part, the value as an integer. |
unit: CowRcStr<'a> | The unit, e.g. "px" in |
WhiteSpace(&'a str)Comment(&'a str)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.
ColonA : <colon-token>
SemicolonA ; <semicolon-token>
CommaA , <comma-token>
IncludeMatchDashMatchA |= <dash-match-token>
PrefixMatchA ^= <prefix-match-token>
SuffixMatchA $= <suffix-match-token>
SubstringMatchCDOA <!-- <CDO-token>
CDCA --> <CDC-token>
Function(CowRcStr<'a>)The value (name) does not include the ( marker.
ParenthesisBlockA <(-token>
SquareBracketBlockA <[-token>
CurlyBracketBlockA <{-token>
BadUrl(CowRcStr<'a>)A <bad-url-token>
This token always indicates a parse error.
BadString(CowRcStr<'a>)A <bad-string-token>
This token always indicates a parse error.
CloseParenthesisA <)-token>
When obtained from one of the Parser::next* methods,
this token is always unmatched and indicates a parse error.
CloseSquareBracketA <]-token>
When obtained from one of the Parser::next* methods,
this token is always unmatched and indicates a parse error.
CloseCurlyBracketA <}-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]
impl<'a> Token<'a>pub fn is_parse_error(&self) -> bool[src]
pub fn is_parse_error(&self) -> boolReturn 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]
impl<'a> Token<'a>pub fn serialization_type(&self) -> TokenSerializationType[src]
pub fn serialization_type(&self) -> TokenSerializationTypeCategorize 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]
impl<'a> PartialEq for Token<'a>fn eq(&self, other: &Token<'a>) -> bool[src]
fn eq(&self, other: &Token<'a>) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Token<'a>) -> bool[src]
fn ne(&self, other: &Token<'a>) -> boolThis method tests for !=.
impl<'a> Debug for Token<'a>[src]
impl<'a> Debug for Token<'a>fn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl<'a> Clone for Token<'a>[src]
impl<'a> Clone for Token<'a>fn clone(&self) -> Token<'a>[src]
fn clone(&self) -> Token<'a>Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl<'a> ToCss for Token<'a>[src]
impl<'a> ToCss for Token<'a>