11use crate :: cql_to_rust:: { FromRow , FromRowError } ;
22use crate :: frame:: response:: event:: SchemaChangeEvent ;
33use crate :: frame:: types:: vint_decode;
4- use crate :: frame:: value:: { Counter , CqlDate , CqlDuration , CqlTime , CqlTimestamp } ;
4+ use crate :: frame:: value:: { Counter , CqlDate , CqlDuration , CqlTime , CqlTimestamp , CqlTimeuuid } ;
55use crate :: frame:: { frame_errors:: ParseError , types} ;
66use bigdecimal:: BigDecimal ;
77use byteorder:: { BigEndian , ReadBytesExt } ;
@@ -110,7 +110,7 @@ pub enum CqlValue {
110110 TinyInt ( i8 ) ,
111111 /// Nanoseconds since midnight
112112 Time ( CqlTime ) ,
113- Timeuuid ( Uuid ) ,
113+ Timeuuid ( CqlTimeuuid ) ,
114114 Tuple ( Vec < Option < CqlValue > > ) ,
115115 Uuid ( Uuid ) ,
116116 Varint ( BigInt ) ,
@@ -231,7 +231,7 @@ impl CqlValue {
231231 pub fn as_uuid ( & self ) -> Option < Uuid > {
232232 match self {
233233 Self :: Uuid ( u) => Some ( * u) ,
234- Self :: Timeuuid ( u) => Some ( * u) ,
234+ Self :: Timeuuid ( u) => Some ( * u. as_ref ( ) ) ,
235235 _ => None ,
236236 }
237237 }
@@ -285,7 +285,7 @@ impl CqlValue {
285285 }
286286 }
287287
288- pub fn as_timeuuid ( & self ) -> Option < Uuid > {
288+ pub fn as_timeuuid ( & self ) -> Option < CqlTimeuuid > {
289289 match self {
290290 Self :: Timeuuid ( u) => Some ( * u) ,
291291 _ => None ,
@@ -770,7 +770,7 @@ pub fn deser_cql_value(typ: &ColumnType, buf: &mut &[u8]) -> StdResult<CqlValue,
770770 ) ) ) ;
771771 }
772772 let uuid = uuid:: Uuid :: from_slice ( buf) . expect ( "Deserializing Uuid failed." ) ;
773- CqlValue :: Timeuuid ( uuid)
773+ CqlValue :: Timeuuid ( CqlTimeuuid :: from ( uuid) )
774774 }
775775 Duration => {
776776 let months = i32:: try_from ( vint_decode ( buf) ?) ?;
@@ -966,7 +966,7 @@ pub fn deserialize(buf: &mut &[u8]) -> StdResult<Result, ParseError> {
966966#[ cfg( test) ]
967967mod tests {
968968 use crate as scylla;
969- use crate :: frame:: value:: { Counter , CqlDate , CqlDuration , CqlTime , CqlTimestamp } ;
969+ use crate :: frame:: value:: { Counter , CqlDate , CqlDuration , CqlTime , CqlTimestamp , CqlTimeuuid } ;
970970 use bigdecimal:: BigDecimal ;
971971 use num_bigint:: BigInt ;
972972 use num_bigint:: ToBigInt ;
@@ -993,9 +993,10 @@ mod tests {
993993 let uuid_serialize = super :: deser_cql_value ( & ColumnType :: Uuid , uuid_slice) . unwrap ( ) ;
994994 assert_eq ! ( uuid_serialize, CqlValue :: Uuid ( my_uuid) ) ;
995995
996+ let my_timeuuid = CqlTimeuuid :: from_str ( "00000000000000000000000000000001" ) . unwrap ( ) ;
996997 let time_uuid_serialize =
997998 super :: deser_cql_value ( & ColumnType :: Timeuuid , uuid_slice) . unwrap ( ) ;
998- assert_eq ! ( time_uuid_serialize, CqlValue :: Timeuuid ( my_uuid ) ) ;
999+ assert_eq ! ( time_uuid_serialize, CqlValue :: Timeuuid ( my_timeuuid ) ) ;
9991000
10001001 let my_ip = "::1" . parse ( ) . unwrap ( ) ;
10011002 let ip_buf: Vec < u8 > = vec ! [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 ] ;
@@ -1754,7 +1755,7 @@ mod tests {
17541755 match cql_val {
17551756 CqlValue :: Timeuuid ( uuid) => {
17561757 assert_eq ! ( uuid. as_bytes( ) , uuid_bytes) ;
1757- assert_eq ! ( Uuid :: parse_str ( uuid_str) . unwrap( ) , uuid) ;
1758+ assert_eq ! ( CqlTimeuuid :: from_str ( uuid_str) . unwrap( ) , uuid) ;
17581759 }
17591760 _ => panic ! ( "Timeuuid parsed as wrong CqlValue" ) ,
17601761 }
0 commit comments