Enum cssparser::Token
[−]
[src]
pub enum Token<'a> { Ident(Cow<'a, str>), AtKeyword(Cow<'a, str>), Hash(Cow<'a, str>), IDHash(Cow<'a, str>), QuotedString(Cow<'a, str>), UnquotedUrl(Cow<'a, str>), Delim(char), Number(NumericValue), Percentage(PercentageValue), Dimension(NumericValue, Cow<'a, str>), UnicodeRange(u32, u32), WhiteSpace(&'a str), Comment(&'a str), Colon, Semicolon, Comma, IncludeMatch, DashMatch, PrefixMatch, SuffixMatch, SubstringMatch, Column, CDO, CDC, Function(Cow<'a, str>), ParenthesisBlock, SquareBracketBlock, CurlyBracketBlock, BadUrl, BadString, CloseParenthesis, CloseSquareBracket, CloseCurlyBracket, }
One of the pieces the CSS input is broken into.
Some components use CowString
in order to borrow from the original input string
and avoid allocating/copying when possible.
Variants
Ident(Cow<'a, str>)
AtKeyword(Cow<'a, str>)
The value does not include the @
marker.
Hash(Cow<'a, str>)
A <hash-token>
with the type flag set to "unrestricted"
The value does not include the #
marker.
IDHash(Cow<'a, str>)
A <hash-token>
with the type flag set to "id"
The value does not include the #
marker.
QuotedString(Cow<'a, str>)
The value does not include the quotes.
UnquotedUrl(Cow<'a, str>)
A <url-token>
or url( <string-token> )
function
The value does not include the url(
)
markers or the quotes.
Delim(char)
A <delim-token>
Number(NumericValue)
Percentage(PercentageValue)
Dimension(NumericValue, Cow<'a, str>)
UnicodeRange(u32, u32)
Components are the start and end code points, respectively.
The tokenizer only reads up to 6 hex digit (up to 0xFF_FFFF), but does not check that code points are within the range of Unicode (up to U+10_FFFF).
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.
Colon
A :
<colon-token>
Semicolon
A ;
<semicolon-token>
Comma
A ,
<comma-token>
IncludeMatch
DashMatch
A |=
<dash-match-token>
PrefixMatch
A ^=
<prefix-match-token>
SuffixMatch
A $=
<suffix-match-token>
SubstringMatch
Column
A ||
<column-token>
CDO
A <!--
<CDO-token>
CDC
A -->
<CDC-token>
Function(Cow<'a, str>)
The value (name) does not include the (
marker.
ParenthesisBlock
A <(-token>
SquareBracketBlock
A <[-token>
CurlyBracketBlock
A <{-token>
BadUrl
A <bad-url-token>
This token always indicates a parse error.
BadString
A <bad-string-token>
This token always indicates a parse error.
CloseParenthesis
A <)-token>
When obtained from one of the Parser::next*
methods,
this token is always unmatched and indicates a parse error.
CloseSquareBracket
A <]-token>
When obtained from one of the Parser::next*
methods,
this token is always unmatched and indicates a parse error.
CloseCurlyBracket
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]
fn is_parse_error(&self) -> bool
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]
fn serialization_type(&self) -> TokenSerializationType
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> Clone for 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
Performs copy-assignment from source
. Read more
impl<'a> Debug for Token<'a>
[src]
impl<'a> PartialEq for Token<'a>
[src]
fn eq(&self, __arg_0: &Token<'a>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Token<'a>) -> bool
This method tests for !=
.
impl<'a> ToCss for Token<'a>
[src]
fn to_css<W>(&self, dest: &mut W) -> Result where W: Write
Serialize self
in CSS syntax, writing to dest
.
fn to_css_string(&self) -> String
Serialize self
in CSS syntax and return a string. Read more
fn fmt_to_css<W>(&self, dest: &mut W) -> Result where W: Write
Serialize self
in CSS syntax and return a result compatible with std::fmt::Show
. Read more