#[non_exhaustive]pub enum CqlValue {
Show 27 variants
Ascii(String),
Boolean(bool),
Blob(Vec<u8>),
Counter(Counter),
Decimal(CqlDecimal),
Date(CqlDate),
Double(f64),
Duration(CqlDuration),
Empty,
Float(f32),
Int(i32),
BigInt(i64),
Text(String),
Timestamp(CqlTimestamp),
Inet(IpAddr),
List(Vec<CqlValue>),
Map(Vec<(CqlValue, CqlValue)>),
Set(Vec<CqlValue>),
UserDefinedType {
keyspace: String,
name: String,
fields: Vec<(String, Option<CqlValue>)>,
},
SmallInt(i16),
TinyInt(i8),
Time(CqlTime),
Timeuuid(CqlTimeuuid),
Tuple(Vec<Option<CqlValue>>),
Uuid(Uuid),
Varint(CqlVarint),
Vector(Vec<CqlValue>),
}
Expand description
Represents all possible CQL values that can be returned by the database.
This type can represent a CQL value of any type. Therefore, it should be used in places where dynamic capabilities are needed, while, for efficiency purposes, avoided in places where the type of the value is known in the compile time.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Ascii(String)
ASCII-only string.
Boolean(bool)
Boolean value.
Blob(Vec<u8>)
Binary data of any length.
Counter(Counter)
Counter value, represented as a 64-bit integer.
Decimal(CqlDecimal)
Variable-precision decimal.
Date(CqlDate)
Days since -5877641-06-23 i.e. 2^31 days before unix epoch Can be converted to chrono::NaiveDate (-262145-1-1 to 262143-12-31) using TryInto.
Double(f64)
64-bit IEEE-754 floating point number.
Duration(CqlDuration)
A duration with nanosecond precision.
Empty
An empty value, which is distinct from null and is some DB legacy.
Float(f32)
32-bit IEEE-754 floating point number.
Int(i32)
32-bit signed integer.
BigInt(i64)
64-bit signed integer.
Text(String)
UTF-8 encoded string.
Timestamp(CqlTimestamp)
Milliseconds since unix epoch.
Inet(IpAddr)
IPv4 or IPv6 address.
List(Vec<CqlValue>)
A list of CQL values of the same types.
Map(Vec<(CqlValue, CqlValue)>)
A map of CQL values, whose all keys have the same type and all values have the same type.
Set(Vec<CqlValue>)
A set of CQL values of the same types.
UserDefinedType
A user-defined type (UDT) value. UDT is composed of fields, each with a name and an optional value of its own type.
Fields
SmallInt(i16)
16-bit signed integer.
TinyInt(i8)
8-bit signed integer.
Time(CqlTime)
Nanoseconds since midnight.
Timeuuid(CqlTimeuuid)
Version 1 UUID, generally used as a “conflict-free” timestamp.
Tuple(Vec<Option<CqlValue>>)
A tuple of CQL values of independent types each, where each element can be None
if the value is null. The length of the tuple is part of its CQL type.
Uuid(Uuid)
Universally unique identifier (UUID) of any version.
Varint(CqlVarint)
Arbitrary-precision integer.
Vector(Vec<CqlValue>)
A vector of CQL values of the same type. The length of the vector is part of its CQL type.
Implementations§
Source§impl CqlValue
impl CqlValue
Sourcepub fn as_ascii(&self) -> Option<&String>
pub fn as_ascii(&self) -> Option<&String>
Casts the value to ASCII string if it is of that type.
Sourcepub fn as_cql_date(&self) -> Option<CqlDate>
pub fn as_cql_date(&self) -> Option<CqlDate>
Casts the value to CQL Date if it is of that type.
Sourcepub fn as_cql_timestamp(&self) -> Option<CqlTimestamp>
pub fn as_cql_timestamp(&self) -> Option<CqlTimestamp>
Casts the value to CQL Timestamp if it is of that type.
Sourcepub fn as_cql_time(&self) -> Option<CqlTime>
pub fn as_cql_time(&self) -> Option<CqlTime>
Casts the value to CQL Time if it is of that type.
Sourcepub fn as_cql_duration(&self) -> Option<CqlDuration>
pub fn as_cql_duration(&self) -> Option<CqlDuration>
Casts the value to CQL Duration if it is of that type.
Sourcepub fn as_counter(&self) -> Option<Counter>
pub fn as_counter(&self) -> Option<Counter>
Casts the value to CQL Counter if it is of that type.
Sourcepub fn as_boolean(&self) -> Option<bool>
pub fn as_boolean(&self) -> Option<bool>
Casts the value to bool if it is of that type.
Sourcepub fn as_double(&self) -> Option<f64>
pub fn as_double(&self) -> Option<f64>
Casts the value to double-precision float if it is of that type.
Sourcepub fn as_float(&self) -> Option<f32>
pub fn as_float(&self) -> Option<f32>
Casts the value to single-precision float if it is of that type.
Sourcepub fn as_int(&self) -> Option<i32>
pub fn as_int(&self) -> Option<i32>
Casts the value to 32-bit signed integer if it is of that type.
Sourcepub fn as_bigint(&self) -> Option<i64>
pub fn as_bigint(&self) -> Option<i64>
Casts the value to 64-bit signed integer if it is of that type.
Sourcepub fn as_tinyint(&self) -> Option<i8>
pub fn as_tinyint(&self) -> Option<i8>
Casts the value to 8-bit signed integer if it is of that type.
Sourcepub fn as_smallint(&self) -> Option<i16>
pub fn as_smallint(&self) -> Option<i16>
Casts the value to 16-bit signed integer if it is of that type.
Sourcepub fn as_blob(&self) -> Option<&Vec<u8>>
pub fn as_blob(&self) -> Option<&Vec<u8>>
Casts the value to a byte sequence if it is of blob
type.
Sourcepub fn as_text(&self) -> Option<&String>
pub fn as_text(&self) -> Option<&String>
Casts the value to UTF-8 encoded string if it is of text
type.
Sourcepub fn as_timeuuid(&self) -> Option<CqlTimeuuid>
pub fn as_timeuuid(&self) -> Option<CqlTimeuuid>
Casts the value to CQL Timeuuid if it is of that type.
Sourcepub fn into_string(self) -> Option<String>
pub fn into_string(self) -> Option<String>
Converts the value to string if it is of ascii
or text
type.
Sourcepub fn into_blob(self) -> Option<Vec<u8>>
pub fn into_blob(self) -> Option<Vec<u8>>
Converts the value to a byte sequence if it is of blob
type.
Sourcepub fn as_inet(&self) -> Option<IpAddr>
pub fn as_inet(&self) -> Option<IpAddr>
Casts the value to an IP address if it is of inet
type.
Sourcepub fn as_list(&self) -> Option<&Vec<CqlValue>>
pub fn as_list(&self) -> Option<&Vec<CqlValue>>
Casts the value to a vec of CQL values if it is of list
type.
Sourcepub fn as_set(&self) -> Option<&Vec<CqlValue>>
pub fn as_set(&self) -> Option<&Vec<CqlValue>>
Casts the value to a vec of CQL values if it is of set
type.
Sourcepub fn as_map(&self) -> Option<&Vec<(CqlValue, CqlValue)>>
pub fn as_map(&self) -> Option<&Vec<(CqlValue, CqlValue)>>
Casts the value to a vec of pairs of CQL values if it is of map
type,
where each pair is a key-value pair.
Sourcepub fn as_udt(&self) -> Option<&Vec<(String, Option<CqlValue>)>>
pub fn as_udt(&self) -> Option<&Vec<(String, Option<CqlValue>)>>
Casts the value to a user-defined type (UDT) if it is of that type. The UDT is represented as a vector of pairs, where each pair consists of a field name and an optional (=nullable) value.
Sourcepub fn into_vec(self) -> Option<Vec<CqlValue>>
pub fn into_vec(self) -> Option<Vec<CqlValue>>
Converts the value to a vector of CQL values if it is of list
or set
type.
Sourcepub fn into_pair_vec(self) -> Option<Vec<(CqlValue, CqlValue)>>
pub fn into_pair_vec(self) -> Option<Vec<(CqlValue, CqlValue)>>
Converts the value to a vec of pairs of CQL values if it is of map
type,
where each pair is a key-value pair.
Sourcepub fn into_udt_pair_vec(self) -> Option<Vec<(String, Option<CqlValue>)>>
pub fn into_udt_pair_vec(self) -> Option<Vec<(String, Option<CqlValue>)>>
Converts the value to a vec of pairs if it is a user-defined type (UDT). Each pair consists of a field name and an optional (=nullable) value.
Sourcepub fn into_cql_varint(self) -> Option<CqlVarint>
pub fn into_cql_varint(self) -> Option<CqlVarint>
Converts the value to CQL Varint if it is of that type.
Sourcepub fn into_cql_decimal(self) -> Option<CqlDecimal>
pub fn into_cql_decimal(self) -> Option<CqlDecimal>
Converts the value to CQL Decimal if it is of that type.
Trait Implementations§
Source§impl<'frame, 'metadata> DeserializeValue<'frame, 'metadata> for CqlValue
impl<'frame, 'metadata> DeserializeValue<'frame, 'metadata> for CqlValue
Source§fn type_check(_typ: &ColumnType<'_>) -> Result<(), TypeCheckError>
fn type_check(_typ: &ColumnType<'_>) -> Result<(), TypeCheckError>
Source§fn deserialize(
typ: &'metadata ColumnType<'metadata>,
v: Option<FrameSlice<'frame>>,
) -> Result<Self, DeserializationError>
fn deserialize( typ: &'metadata ColumnType<'metadata>, v: Option<FrameSlice<'frame>>, ) -> Result<Self, DeserializationError>
Source§impl Display for CqlValue
Displays a CqlValue. The syntax should resemble the CQL literal syntax
(but no guarantee is given that it’s always the same).
impl Display for CqlValue
Displays a CqlValue. The syntax should resemble the CQL literal syntax (but no guarantee is given that it’s always the same).
Source§impl SerializeValue for CqlValue
impl SerializeValue for CqlValue
Source§fn serialize<'b>(
&self,
typ: &ColumnType<'_>,
writer: CellWriter<'b>,
) -> Result<WrittenCellProof<'b>, SerializationError>
fn serialize<'b>( &self, typ: &ColumnType<'_>, writer: CellWriter<'b>, ) -> Result<WrittenCellProof<'b>, SerializationError>
impl StructuralPartialEq for CqlValue
Auto Trait Implementations§
impl Freeze for CqlValue
impl RefUnwindSafe for CqlValue
impl Send for CqlValue
impl Sync for CqlValue
impl Unpin for CqlValue
impl UnwindSafe for CqlValue
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more