File tree Expand file tree Collapse file tree 4 files changed +39
-6
lines changed Expand file tree Collapse file tree 4 files changed +39
-6
lines changed Original file line number Diff line number Diff line change 3939 - [ Counter] ( data-types/counter.md )
4040 - [ Blob] ( data-types/blob.md )
4141 - [ Inet] ( data-types/inet.md )
42- - [ Uuid, Timeuuid] ( data-types/uuid.md )
42+ - [ Uuid] ( data-types/uuid.md )
43+ - [ Timeuuid] ( data-types/timeuuid.md )
4344 - [ Date] ( data-types/date.md )
4445 - [ Time] ( data-types/time.md )
4546 - [ Timestamp] ( data-types/timestamp.md )
Original file line number Diff line number Diff line change @@ -20,7 +20,8 @@ Database types and their Rust equivalents:
2020* ` Counter ` <----> ` value::Counter `
2121* ` Blob ` <----> ` Vec<u8> `
2222* ` Inet ` <----> ` std::net::IpAddr `
23- * ` Uuid ` , ` Timeuuid ` <----> ` uuid::Uuid `
23+ * ` Uuid ` <----> ` uuid::Uuid `
24+ * ` Timeuuid ` <----> ` value::CqlTimeuuid `
2425* ` Date ` <----> ` value::CqlDate ` , ` chrono::NaiveDate ` , ` time::Date `
2526* ` Time ` <----> ` value::CqlTime ` , ` chrono::NaiveTime ` , ` time::Time `
2627* ` Timestamp ` <----> ` value::CqlTimestamp ` , ` chrono::DateTime<Utc> ` , ` time::OffsetDateTime `
@@ -45,6 +46,7 @@ Database types and their Rust equivalents:
4546 blob
4647 inet
4748 uuid
49+ timeuuid
4850 date
4951 time
5052 timestamp
Original file line number Diff line number Diff line change 1+ # Timeuuid
2+
3+ ` Timeuuid ` is represented as ` value::CqlTimeuuid ` .
4+ ` value::CqlTimeuuid ` is a wrapper for ` uuid::Uuid ` with custom ordering logic
5+ which follows Scylla/Cassandra semantics.
6+
7+ ``` rust
8+ # extern crate scylla;
9+ # use scylla :: Session ;
10+ # use std :: error :: Error ;
11+ # use std :: str :: FromStr ;
12+ # async fn check_only_compiles (session : & Session ) -> Result <(), Box <dyn Error >> {
13+ use scylla :: IntoTypedRows ;
14+ use scylla :: frame :: value :: CqlTimeuuid ;
15+
16+ // Insert some timeuuid into the table
17+ let to_insert : CqlTimeuuid = CqlTimeuuid :: from_str (" 8e14e760-7fa8-11eb-bc66-000000000001" )? ;
18+ session
19+ . query (" INSERT INTO keyspace.table (a) VALUES(?)" , (to_insert ,))
20+ . await ? ;
21+
22+ // Read timeuuid from the table
23+ if let Some (rows ) = session . query (" SELECT a FROM keyspace.table" , & []). await ? . rows {
24+ for row in rows . into_typed :: <(CqlTimeuuid ,)>() {
25+ let (timeuuid_value ,): (CqlTimeuuid ,) = row ? ;
26+ }
27+ }
28+ # Ok (())
29+ # }
30+ ```
Original file line number Diff line number Diff line change 1- # Uuid, Timeuuid
1+ # Uuid
22
3- ` Uuid ` and ` Timeuuid ` are represented as ` uuid::Uuid `
3+ ` Uuid ` is represented as ` uuid::Uuid ` .
44
55``` rust
66# extern crate scylla;
1111use scylla :: IntoTypedRows ;
1212use uuid :: Uuid ;
1313
14- // Insert some uuid/timeuuid into the table
14+ // Insert some uuid into the table
1515let to_insert : Uuid = Uuid :: parse_str (" 8e14e760-7fa8-11eb-bc66-000000000001" )? ;
1616session
1717 . query (" INSERT INTO keyspace.table (a) VALUES(?)" , (to_insert ,))
1818 . await ? ;
1919
20- // Read uuid/timeuuid from the table
20+ // Read uuid from the table
2121if let Some (rows ) = session . query (" SELECT a FROM keyspace.table" , & []). await ? . rows {
2222 for row in rows . into_typed :: <(Uuid ,)>() {
2323 let (uuid_value ,): (Uuid ,) = row ? ;
You can’t perform that action at this time.
0 commit comments