pub enum Token {
Show 31 variants
Word(Word),
Number(String),
Char(char),
SingleQuotedString(String),
NationalStringLiteral(String),
HexStringLiteral(String),
Comma,
Whitespace(Whitespace),
Eq,
Neq([char; 2]),
Lt,
Gt,
LtEq,
GtEq,
Plus,
Minus,
Mult,
Div,
Mod,
LParen,
RParen,
Period,
Colon,
DoubleColon,
SemiColon,
Backslash,
LBracket,
RBracket,
Ampersand,
LBrace,
RBrace,
}
Expand description
SQL Token enumeration
Variants§
Word(Word)
A keyword (like SELECT) or an optionally quoted SQL identifier
Number(String)
An unsigned numeric literal
Char(char)
A character that could not be tokenized
SingleQuotedString(String)
Single quoted string: i.e: ‘string’
NationalStringLiteral(String)
“National” string literal: i.e: N’string’
HexStringLiteral(String)
Hexadecimal string literal: i.e.: X’deadbeef’
Comma
Comma
Whitespace(Whitespace)
Whitespace (space, tab, etc)
Eq
Equality operator =
Neq([char; 2])
Not Equals operator <>
(or !=
in some dialects)
Lt
Less Than operator <
Gt
Greater han operator >
LtEq
Less Than Or Equals operator <=
GtEq
Greater Than Or Equals operator >=
Plus
Plus operator +
Minus
Minus operator -
Mult
Multiplication operator *
Div
Division operator /
Mod
Modulo Operator %
LParen
Left parenthesis (
RParen
Right parenthesis )
Period
Period (used for compound identifiers or projections into nested types)
Colon
Colon :
DoubleColon
DoubleColon ::
(used for casting in postgresql)
SemiColon
SemiColon ;
used as separator for COPY and payload
Backslash
Backslash \
used in terminating the COPY payload with \.
LBracket
Left bracket [
RBracket
Right bracket ]
Ampersand
Ampersand &
LBrace
Left brace {
RBrace
Right brace }
Implementations§
Source§impl Token
impl Token
Sourcepub fn new(word: &str, quote_style: Option<char>) -> Self
pub fn new(word: &str, quote_style: Option<char>) -> Self
Creates a new token. quote style is None for integers.
Sourcepub fn get_value(&self) -> String
pub fn get_value(&self) -> String
Gets the value of the column encoded in an string. For numbers use get_number
Sourcepub fn get_number(&self) -> Option<f64>
pub fn get_number(&self) -> Option<f64>
If the token contains a number and it can be parsed, returns Some(number). None if not.
Sourcepub fn is_keyword(&self) -> bool
pub fn is_keyword(&self) -> bool
returns if the Token contains a keyword
Sourcepub fn get_quote_style(&self) -> Option<char>
pub fn get_quote_style(&self) -> Option<char>
gets the quote style. None if none or it doesn’t apply