Enum taos_query::common::Ty
source · #[repr(u8)]#[non_exhaustive]pub enum Ty {
Show 15 variants
Bool,
TinyInt,
SmallInt,
Int,
BigInt,
UTinyInt,
USmallInt,
UInt,
UBigInt,
Float,
Double,
Timestamp,
VarChar,
NChar,
Json,
}
Expand description
TDengine data type enumeration.
enum | int | sql name | rust type |
---|---|---|---|
Null | 0 | NULL | None |
Bool | 1 | BOOL | bool |
TinyInt | 2 | TINYINT | i8 |
SmallInt | 3 | SMALLINT | i16 |
Int | 4 | INT | i32 |
BitInt | 5 | BIGINT | i64 |
Float | 6 | FLOAT | f32 |
Double | 7 | DOUBLE | f64 |
VarChar | 8 | BINARY/VARCHAR | str/String |
Timestamp | 9 | TIMESTAMP | i64 |
NChar | 10 | NCHAR | str/String |
UTinyInt | 11 | TINYINT UNSIGNED | u8 |
USmallInt | 12 | SMALLINT UNSIGNED | u16 |
UInt | 13 | INT UNSIGNED | u32 |
UBigInt | 14 | BIGINT UNSIGNED | u64 |
Json | 15 | JSON | serde_json::Value |
Note:
- VarChar sql name is BINARY in v2, and VARCHAR in v3.
- Decimal/Blob/MediumBlob is not supported in 2.0/3.0 .
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Bool
The BOOL
type in sql, will be represented as bool in Rust.
TinyInt
TINYINT
type in sql, will be represented in Rust as i8.
SmallInt
SMALLINT
type in sql, will be represented in Rust as i16.
Int
INT
type in sql, will be represented in Rust as i32.
BigInt
BIGINT
type in sql, will be represented in Rust as i64.
UTinyInt
UTinyInt, tinyint unsigned
in sql, u8 in Rust.
USmallInt
12: USmallInt, smallint unsigned
in sql, u16 in Rust.
UInt
13: UInt, int unsigned
in sql, u32 in Rust.
UBigInt
14: UBigInt, bigint unsigned
in sql, u64 in Rust.
Float
6: Float, float
type in sql, will be represented in Rust as f32.
Double
7: Double, tinyint
type in sql, will be represented in Rust as f64.
Timestamp
9: Timestamp, timestamp
type in sql, will be represented as i64 in Rust.
But can be deserialized to chrono::naive::NaiveDateTime or String.
VarChar
8: VarChar, binary
type in sql for TDengine 2.x, varchar
for TDengine 3.x,
will be represented in Rust as &str or String. This type of data be deserialized to Vec<u8>
.
NChar
10: NChar, nchar
type in sql, the recommended way in TDengine to store utf-8 String.
Json
15: Json, json
tag in sql, will be represented as serde_json::value::Value in Rust.
Implementations§
source§impl Ty
impl Ty
sourcepub const fn is_var_type(&self) -> bool
pub const fn is_var_type(&self) -> bool
Var type is one of Ty::VarChar, Ty::VarBinary, Ty::NChar.
pub const fn is_json(&self) -> bool
sourcepub const fn is_primitive(&self) -> bool
pub const fn is_primitive(&self) -> bool
Is one of boolean/integers/float/double/decimal
sourcepub const fn fixed_length(&self) -> usize
pub const fn fixed_length(&self) -> usize
Get fixed length if the type is primitive.