[−][src]Enum cssparser::Token
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>
Fields of Number
Fields of Percentage
Fields of Dimension
has_sign: boolWhether the number had a + or - sign.
This is used is some cases like the <An+B> micro syntax. (See the parse_nth function.)
value: f32The 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 12px
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.
A : <colon-token>
A ; <semicolon-token>
A , <comma-token>
A |= <dash-match-token>
A ^= <prefix-match-token>
A $= <suffix-match-token>
A <!-- <CDO-token>
A --> <CDC-token>
Function(CowRcStr<'a>)The value (name) does not include the ( marker.
A <(-token>
A <[-token>
A <{-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.
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]
pub fn is_parse_error(&self) -> bool[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]
pub fn serialization_type(&self) -> TokenSerializationType[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> ToCss for Token<'a>[src]
fn to_css<W>(&self, dest: &mut W) -> Result where
W: Write, [src]
W: Write,
fn to_css_string(&self) -> String[src]
impl<'a> Clone for Token<'a>[src]
impl<'a> PartialEq<Token<'a>> for Token<'a>[src]
impl<'a> Debug for Token<'a>[src]
Auto Trait Implementations
impl<'a> !Send for Token<'a>
impl<'a> !Sync for Token<'a>
impl<'a> Unpin for Token<'a>
impl<'a> UnwindSafe for Token<'a>
impl<'a> !RefUnwindSafe for Token<'a>
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> From<T> for T[src]
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,