Skip to content

Commit 1958216

Browse files
committed
docs: update uuid/timeuuid info
1 parent 0db6583 commit 1958216

File tree

4 files changed

+39
-6
lines changed

4 files changed

+39
-6
lines changed

docs/source/SUMMARY.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
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)

docs/source/data-types/data-types.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff 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

docs/source/data-types/timeuuid.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
```

docs/source/data-types/uuid.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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;
@@ -11,13 +11,13 @@
1111
use scylla::IntoTypedRows;
1212
use uuid::Uuid;
1313

14-
// Insert some uuid/timeuuid into the table
14+
// Insert some uuid into the table
1515
let to_insert: Uuid = Uuid::parse_str("8e14e760-7fa8-11eb-bc66-000000000001")?;
1616
session
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
2121
if 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?;

0 commit comments

Comments
 (0)