From 0262a314d3f074d01b80c431c9e6b3669cb966a5 Mon Sep 17 00:00:00 2001 From: Piotr Dulikowski Date: Thu, 30 Mar 2023 08:23:53 +0200 Subject: [PATCH] documentation: adjust to the new traits Examples in the documentation are now adjusted to the new deserialization API, and the examples there finally compile. --- README.md | 2 +- docs/source/data-types/blob.md | 2 +- docs/source/data-types/collections.md | 12 ++-- docs/source/data-types/counter.md | 2 +- docs/source/data-types/date.md | 4 +- docs/source/data-types/decimal.md | 2 +- docs/source/data-types/duration.md | 2 +- docs/source/data-types/inet.md | 2 +- docs/source/data-types/primitive.md | 14 ++--- docs/source/data-types/text.md | 2 +- docs/source/data-types/time.md | 2 +- docs/source/data-types/timestamp.md | 2 +- docs/source/data-types/tuple.md | 2 +- docs/source/data-types/udt.md | 7 ++- docs/source/data-types/uuid.md | 2 +- docs/source/data-types/varint.md | 2 +- docs/source/queries/paged.md | 4 +- docs/source/queries/result.md | 90 ++++++--------------------- docs/source/queries/simple.md | 7 ++- docs/source/quickstart/example.md | 2 +- docs/source/tracing/basic.md | 6 +- docs/source/tracing/paged.md | 12 ++-- 22 files changed, 68 insertions(+), 114 deletions(-) diff --git a/README.md b/README.md index 60f96820bb..15d82dec7f 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ let uri = "127.0.0.1:9042"; let session: Session = SessionBuilder::new().known_node(uri).build().await?; let result = session.query("SELECT a, b, c FROM ks.t", &[]).await?; -let mut iter = result.rows_typed::<(i32, i32, String)>()?; +let mut iter = result.rows::<(i32, i32, String)>()?; while let Some((a, b, c)) = iter.next().transpose()? { println!("a, b, c: {}, {}, {}", a, b, c); } diff --git a/docs/source/data-types/blob.md b/docs/source/data-types/blob.md index 83ef1306e8..c3e9d40377 100644 --- a/docs/source/data-types/blob.md +++ b/docs/source/data-types/blob.md @@ -18,7 +18,7 @@ session // Read blobs from the table let result = session.query("SELECT a FROM keyspace.table", &[]).await?; -let mut iter = result.rows_typed::<(Vec,)>()?; +let mut iter = result.rows::<(Vec,)>()?; while let Some((blob_value,)) = iter.next().transpose()? { println!("{:?}", blob_value); } diff --git a/docs/source/data-types/collections.md b/docs/source/data-types/collections.md index 5a1570ad3d..cc1c256158 100644 --- a/docs/source/data-types/collections.md +++ b/docs/source/data-types/collections.md @@ -18,7 +18,7 @@ session // Read a list of ints from the table let result = session.query("SELECT a FROM keyspace.table", &[]).await?; -let mut iter = result.rows_typed::<(Vec,)>()?; +let mut iter = result.rows::<(Vec,)>()?; while let Some((list_value,)) = iter.next().transpose()? { println!("{:?}", list_value); } @@ -44,7 +44,7 @@ session // Read a set of ints from the table let result = session.query("SELECT a FROM keyspace.table", &[]).await?; -let mut iter = result.rows_typed::<(Vec,)>()?; +let mut iter = result.rows::<(Vec,)>()?; while let Some((list_value,)) = iter.next().transpose()? { println!("{:?}", list_value); } @@ -68,7 +68,7 @@ session // Read a set of ints from the table let result = session.query("SELECT a FROM keyspace.table", &[]).await?; -let mut iter = result.rows_typed::<(HashSet,)>()?; +let mut iter = result.rows::<(HashSet,)>()?; while let Some((list_value,)) = iter.next().transpose()? { println!("{:?}", list_value); } @@ -92,7 +92,7 @@ session // Read a set of ints from the table let result = session.query("SELECT a FROM keyspace.table", &[]).await?; -let mut iter = result.rows_typed::<(BTreeSet,)>()?; +let mut iter = result.rows::<(BTreeSet,)>()?; while let Some((list_value,)) = iter.next().transpose()? { println!("{:?}", list_value); } @@ -121,7 +121,7 @@ session // Read a map from the table let result = session.query("SELECT a FROM keyspace.table", &[]).await?; -let mut iter = result.rows_typed::<(HashMap,)>()?; +let mut iter = result.rows::<(HashMap,)>()?; while let Some((map_value,)) = iter.next().transpose()? { println!("{:?}", map_value); } @@ -147,7 +147,7 @@ session // Read a map from the table let result = session.query("SELECT a FROM keyspace.table", &[]).await?; -let mut iter = result.rows_typed::<(BTreeMap,)>()?; +let mut iter = result.rows::<(BTreeMap,)>()?; while let Some((map_value,)) = iter.next().transpose()? { println!("{:?}", map_value); } diff --git a/docs/source/data-types/counter.md b/docs/source/data-types/counter.md index 37eb46439f..9379e45a2c 100644 --- a/docs/source/data-types/counter.md +++ b/docs/source/data-types/counter.md @@ -12,7 +12,7 @@ use scylla::frame::value::Counter; // Read counter from the table let result = session.query("SELECT c FROM keyspace.table", &[]).await?; -let mut iter = result.rows_typed::<(Counter,)>()?; +let mut iter = result.rows::<(Counter,)>()?; while let Some((counter_value,)) = iter.next().transpose()? { let counter_int_value: i64 = counter_value.0; println!("{}", counter_int_value); diff --git a/docs/source/data-types/date.md b/docs/source/data-types/date.md index e656e8192a..c39a3f8641 100644 --- a/docs/source/data-types/date.md +++ b/docs/source/data-types/date.md @@ -25,7 +25,7 @@ session // Read NaiveDate from the table let result = session.query("SELECT a FROM keyspace.table", &[]).await?; -let mut iter = result.rows_typed::<(NaiveDate,)>()?; +let mut iter = result.rows::<(NaiveDate,)>()?; while let Some((date_value,)) = iter.next().transpose()? { println!("{:?}", date_value); } @@ -53,7 +53,7 @@ session // Read raw Date from the table let result = session.query("SELECT a FROM keyspace.table", &[]).await?; -let mut iter = result.rows_typed::<(Date,)>()?; +let mut iter = result.rows::<(Date,)>()?; while let Some((date_value,)) = iter.next().transpose()? { println!("{:?}", date_value); } diff --git a/docs/source/data-types/decimal.md b/docs/source/data-types/decimal.md index c5bc706b9b..02cad1db5f 100644 --- a/docs/source/data-types/decimal.md +++ b/docs/source/data-types/decimal.md @@ -19,7 +19,7 @@ session // Read a decimal from the table let result = session.query("SELECT a FROM keyspace.table", &[]).await?; -let mut iter = result.rows_typed::<(BigDecimal,)>()?; +let mut iter = result.rows::<(BigDecimal,)>()?; while let Some((decimal_value,)) = iter.next().transpose()? { println!("{:?}", decimal_value); } diff --git a/docs/source/data-types/duration.md b/docs/source/data-types/duration.md index 79f9f47080..a59abf3bb5 100644 --- a/docs/source/data-types/duration.md +++ b/docs/source/data-types/duration.md @@ -17,7 +17,7 @@ session // Read duration from the table let result = session.query("SELECT a FROM keyspace.table", &[]).await?; -let mut iter = result.rows_typed::<(CqlDuration,)>()?; +let mut iter = result.rows::<(CqlDuration,)>()?; while let Some((duration_value,)) = iter.next().transpose()? { println!("{:?}", duration_value); } diff --git a/docs/source/data-types/inet.md b/docs/source/data-types/inet.md index c7c9f26ee9..7b016ad86d 100644 --- a/docs/source/data-types/inet.md +++ b/docs/source/data-types/inet.md @@ -17,7 +17,7 @@ session // Read inet from the table let result = session.query("SELECT a FROM keyspace.table", &[]).await?; -let mut iter = result.rows_typed::<(IpAddr,)>()?; +let mut iter = result.rows::<(IpAddr,)>()?; while let Some((inet_value,)) = iter.next().transpose()? { println!("{:?}", inet_value); } diff --git a/docs/source/data-types/primitive.md b/docs/source/data-types/primitive.md index 2bc69ce6f0..0c1041ddbb 100644 --- a/docs/source/data-types/primitive.md +++ b/docs/source/data-types/primitive.md @@ -19,7 +19,7 @@ session // Read a bool from the table let result = session.query("SELECT a FROM keyspace.table", &[]).await?; -let mut iter = result.rows_typed::<(bool,)>()?; +let mut iter = result.rows::<(bool,)>()?; while let Some((bool_value,)) = iter.next().transpose()? { println!("{}", bool_value); } @@ -46,7 +46,7 @@ session // Read a tinyint from the table let result = session.query("SELECT a FROM keyspace.table", &[]).await?; -let mut iter = result.rows_typed::<(i8,)>()?; +let mut iter = result.rows::<(i8,)>()?; while let Some((tinyint_value,)) = iter.next().transpose()? { println!("{:?}", tinyint_value); } @@ -73,7 +73,7 @@ session // Read a smallint from the table let result = session.query("SELECT a FROM keyspace.table", &[]).await?; -let mut iter = result.rows_typed::<(i16,)>()?; +let mut iter = result.rows::<(i16,)>()?; while let Some((smallint_value,)) = iter.next().transpose()? { println!("{}", smallint_value); } @@ -100,7 +100,7 @@ session // Read an int from the table let result = session.query("SELECT a FROM keyspace.table", &[]).await?; -let mut iter = result.rows_typed::<(i32,)>()?; +let mut iter = result.rows::<(i32,)>()?; while let Some((int_value,)) = iter.next().transpose()? { println!("{}", int_value); } @@ -127,7 +127,7 @@ session // Read a bigint from the table let result = session.query("SELECT a FROM keyspace.table", &[]).await?; -let mut iter = result.rows_typed::<(i64,)>()?; +let mut iter = result.rows::<(i64,)>()?; while let Some((bigint_value,)) = iter.next().transpose()? { println!("{:?}", bigint_value); } @@ -154,7 +154,7 @@ session // Read a float from the table let result = session.query("SELECT a FROM keyspace.table", &[]).await?; -let mut iter = result.rows_typed::<(f32,)>()?; +let mut iter = result.rows::<(f32,)>()?; while let Some((float_value,)) = iter.next().transpose()? { println!("{:?}", float_value); } @@ -181,7 +181,7 @@ session // Read a double from the table let result = session.query("SELECT a FROM keyspace.table", &[]).await?; -let mut iter = result.rows_typed::<(f64,)>()?; +let mut iter = result.rows::<(f64,)>()?; while let Some((double_value,)) = iter.next().transpose()? { println!("{:?}", double_value); } diff --git a/docs/source/data-types/text.md b/docs/source/data-types/text.md index 6d8fbf2b37..9001fb52e2 100644 --- a/docs/source/data-types/text.md +++ b/docs/source/data-types/text.md @@ -22,7 +22,7 @@ session // Read ascii/text/varchar from the table let result = session.query("SELECT a FROM keyspace.table", &[]).await?; -let mut iter = result.rows_typed::<(String,)>()?; +let mut iter = result.rows::<(String,)>()?; while let Some((text_value,)) = iter.next().transpose()? { println!("{}", text_value); } diff --git a/docs/source/data-types/time.md b/docs/source/data-types/time.md index e669eb45db..fa1aaba7d3 100644 --- a/docs/source/data-types/time.md +++ b/docs/source/data-types/time.md @@ -24,7 +24,7 @@ session // Read time from the table, no need for a wrapper here let result = session.query("SELECT a FROM keyspace.table", &[]).await?; -let mut iter = result.rows_typed::<(Duration,)>()?; +let mut iter = result.rows::<(Duration,)>()?; while let Some((time_value,)) = iter.next().transpose()? { println!("{:?}", time_value); } diff --git a/docs/source/data-types/timestamp.md b/docs/source/data-types/timestamp.md index bff5d4714a..d31d68e84d 100644 --- a/docs/source/data-types/timestamp.md +++ b/docs/source/data-types/timestamp.md @@ -24,7 +24,7 @@ session // Read timestamp from the table, no need for a wrapper here let result = session.query("SELECT a FROM keyspace.table", &[]).await?; -let mut iter = result.rows_typed::<(Duration,)>()?; +let mut iter = result.rows::<(Duration,)>()?; while let Some((timestamp_value,)) = iter.next().transpose()? { println!("{:?}", timestamp_value); } diff --git a/docs/source/data-types/tuple.md b/docs/source/data-types/tuple.md index c56c814913..32c586a91e 100644 --- a/docs/source/data-types/tuple.md +++ b/docs/source/data-types/tuple.md @@ -17,7 +17,7 @@ session // Read a tuple of int and string from the table let result = session.query("SELECT a FROM keyspace.table", &[]).await?; -let mut iter = result.rows_typed::<((i32, String),)>()?; +let mut iter = result.rows::<((i32, String),)>()?; while let Some((tuple_value,)) = iter.next().transpose()? { let int_value: i32 = tuple_value.0; let string_value: String = tuple_value.1; diff --git a/docs/source/data-types/udt.md b/docs/source/data-types/udt.md index c518627945..bbef21985c 100644 --- a/docs/source/data-types/udt.md +++ b/docs/source/data-types/udt.md @@ -14,12 +14,13 @@ To use this type in the driver create a matching struct and derive `IntoUserType # use std::error::Error; # async fn check_only_compiles(session: &Session) -> Result<(), Box> { use scylla::IntoTypedRows; -use scylla::macros::{FromUserType, IntoUserType}; +use scylla::macros::{IntoUserType, DeserializeCql}; use scylla::cql_to_rust::FromCqlVal; +use scylla::types::deserialize::value::DeserializeCql; // Define custom struct that matches User Defined Type created earlier // wrapping field in Option will gracefully handle null field values -#[derive(Debug, IntoUserType, FromUserType)] +#[derive(Debug, IntoUserType, DeserializeCql)] struct MyType { int_val: i32, text_val: Option, @@ -39,7 +40,7 @@ session // Read MyType from the table let result = session.query("SELECT a FROM keyspace.table", &[]).await?; -let mut iter = result.rows_typed::<(MyType,)>()?; +let mut iter = result.rows::<(MyType,)>()?; while let Some((my_type_value,)) = iter.next().transpose()? { println!("{:?}", my_type_value); } diff --git a/docs/source/data-types/uuid.md b/docs/source/data-types/uuid.md index 745dd2c7e6..b8eb25b80d 100644 --- a/docs/source/data-types/uuid.md +++ b/docs/source/data-types/uuid.md @@ -19,7 +19,7 @@ session // Read uuid/timeuuid from the table let result = session.query("SELECT a FROM keyspace.table", &[]).await?; -let mut iter = result.rows_typed::<(Uuid,)>()?; +let mut iter = result.rows::<(Uuid,)>()?; while let Some((uuid_value,)) = iter.next().transpose()? { println!("{:?}", uuid_value); } diff --git a/docs/source/data-types/varint.md b/docs/source/data-types/varint.md index 0abdc13089..cca45215ed 100644 --- a/docs/source/data-types/varint.md +++ b/docs/source/data-types/varint.md @@ -19,7 +19,7 @@ session // Read a varint from the table let result = session.query("SELECT a FROM keyspace.table", &[]).await?; -let mut iter = result.rows_typed::<(BigInt,)>()?; +let mut iter = result.rows::<(BigInt,)>()?; while let Some((varint_value,)) = iter.next().transpose()? { println!("{:?}", varint_value); } diff --git a/docs/source/queries/paged.md b/docs/source/queries/paged.md index dab3672210..83d33199b5 100644 --- a/docs/source/queries/paged.md +++ b/docs/source/queries/paged.md @@ -113,7 +113,7 @@ use scylla::query::Query; let paged_query = Query::new("SELECT a, b, c FROM ks.t").with_page_size(6); let res1 = session.query(paged_query.clone(), &[]).await?; let res2 = session - .query_paged(paged_query.clone(), &[], res1.paging_state) + .query_paged(paged_query.clone(), &[], res1.paging_state()) .await?; # Ok(()) # } @@ -132,7 +132,7 @@ let paged_prepared = session .await?; let res1 = session.execute(&paged_prepared, &[]).await?; let res2 = session - .execute_paged(&paged_prepared, &[], res1.paging_state) + .execute_paged(&paged_prepared, &[], res1.paging_state()) .await?; # Ok(()) # } diff --git a/docs/source/queries/result.md b/docs/source/queries/result.md index 6350eab9ad..686bf83efe 100644 --- a/docs/source/queries/result.md +++ b/docs/source/queries/result.md @@ -2,62 +2,13 @@ `Session::query` and `Session::execute` return a `QueryResult` with rows represented as `Option>`. -### Basic representation -`Row` is a basic representation of a received row. It can be used by itself, but it's a bit awkward to use: -```rust -# extern crate scylla; -# use scylla::Session; -# use std::error::Error; -# async fn check_only_compiles(session: &Session) -> Result<(), Box> { -if let Some(rows) = session.query("SELECT a from ks.tab", &[]).await?.rows { - for row in rows { - let int_value: i32 = row.columns[0].as_ref().unwrap().as_int().unwrap(); - } -} -# Ok(()) -# } -``` - -### Parsing using `into_typed` -The driver provides a way to parse a row as a tuple of Rust types: -```rust -# extern crate scylla; -# use scylla::Session; -# use std::error::Error; -# async fn check_only_compiles(session: &Session) -> Result<(), Box> { -use scylla::IntoTypedRows; - -// Parse row as a single column containing an int value -if let Some(rows) = session.query("SELECT a from ks.tab", &[]).await?.rows { - for row in rows { - let (int_value,): (i32,) = row.into_typed::<(i32,)>()?; - } -} - -// rows.into_typed() converts a Vec of Rows to an iterator of parsing results -if let Some(rows) = session.query("SELECT a from ks.tab", &[]).await?.rows { - for row in rows.into_typed::<(i32,)>() { - let (int_value,): (i32,) = row?; - } -} - -// Parse row as two columns containing an int and text columns -if let Some(rows) = session.query("SELECT a, b from ks.tab", &[]).await?.rows { - for row in rows.into_typed::<(i32, String)>() { - let (int_value, text_value): (i32, String) = row?; - } -} -# Ok(()) -# } -``` - ## Parsing using convenience methods [`QueryResult`](https://docs.rs/scylla/latest/scylla/transport/query_result/struct.QueryResult.html) provides convenience methods for parsing rows. Here are a few of them: -* `rows_typed::()` - returns the rows parsed as the given type -* `maybe_first_row_typed::` - returns `Option` containing first row from the result -* `first_row_typed::` - same as `maybe_first_row`, but fails without the first row -* `single_row_typed::` - same as `first_row`, but fails when there is more than one row +* `rows::()` - returns the rows parsed as the given type +* `maybe_first_row::` - returns `Option` containing first row from the result +* `first_row::` - same as `maybe_first_row`, but fails without the first row +* `single_row::` - same as `first_row`, but fails when there is more than one row * `result_not_rows()` - ensures that query response was not `rows`, helps avoid bugs @@ -67,11 +18,10 @@ Here are a few of them: # use std::error::Error; # async fn check_only_compiles(session: &Session) -> Result<(), Box> { // Parse row as a single column containing an int value -let rows = session +let result = session .query("SELECT a from ks.tab", &[]) - .await? - .rows_typed::<(i32,)>()?; // Same as .rows()?.into_typed() -for row in rows { + .await?; +for row in result.rows::<(i32,)>()? { let (int_value,): (i32,) = row?; } @@ -79,7 +29,7 @@ for row in rows { let first_int_val: Option<(i32,)> = session .query("SELECT a from ks.tab", &[]) .await? - .maybe_first_row_typed::<(i32,)>()?; + .maybe_first_row::<(i32,)>()?; // no_rows fails when the response is rows session.query("INSERT INTO ks.tab (a) VALUES (0)", &[]).await?.result_not_rows()?; @@ -99,10 +49,9 @@ To properly handle `NULL` values parse column as an `Option<>`: use scylla::IntoTypedRows; // Parse row as two columns containing an int and text which might be null -if let Some(rows) = session.query("SELECT a, b from ks.tab", &[]).await?.rows { - for row in rows.into_typed::<(i32, Option)>() { - let (int_value, str_or_null): (i32, Option) = row?; - } +let result = session.query("SELECT a, b from ks.tab", &[]).await?; +for row in result.rows::<(i32, Option)>()? { + let (int_value, str_or_null): (i32, Option) = row?; } # Ok(()) # } @@ -113,7 +62,7 @@ It is possible to receive row as a struct with fields matching the columns.\ The struct must: * have the same number of fields as the number of queried columns * have field types matching the columns being received -* derive `FromRow` +* derive `DeserializeRow` Field names don't need to match column names. ```rust @@ -122,20 +71,19 @@ Field names don't need to match column names. # use std::error::Error; # async fn check_only_compiles(session: &Session) -> Result<(), Box> { use scylla::IntoTypedRows; -use scylla::macros::FromRow; -use scylla::frame::response::cql_to_rust::FromRow; +use scylla::macros::DeserializeRow; +use scylla::types::deserialize::row::DeserializeRow; -#[derive(FromRow)] +#[derive(DeserializeRow)] struct MyRow { age: i32, - name: Option + name: Option, } // Parse row as two columns containing an int and text which might be null -if let Some(rows) = session.query("SELECT a, b from ks.tab", &[]).await?.rows { - for row in rows.into_typed::() { - let my_row: MyRow = row?; - } +let result = session.query("SELECT a, b from ks.tab", &[]).await?; +for row in result.rows::()? { + let my_row: MyRow = row?; } # Ok(()) # } diff --git a/docs/source/queries/simple.md b/docs/source/queries/simple.md index 3979f82927..c45ac0b126 100644 --- a/docs/source/queries/simple.md +++ b/docs/source/queries/simple.md @@ -69,8 +69,9 @@ Here the first `?` will be filled with `2` and the second with `"Some text"`. See [Query values](values.md) for more information about sending values in queries ### Query result -`Session::query` returns `QueryResult` with rows represented as `Option>`.\ -Each row can be parsed as a tuple of rust types using `into_typed`: +`Session::query` returns `QueryResult`. +The result can then be operated on via helper methods which verify that the result is of appropriate type. +Here, we use the `rows` method to check that the response indeed contains rows with a single `int` column: ```rust # extern crate scylla; # use scylla::Session; @@ -80,7 +81,7 @@ use scylla::IntoTypedRows; // Query rows from the table and print them let result = session.query("SELECT a FROM ks.tab", &[]).await?; -let mut iter = result.rows_typed::<(i32,)>()?; +let mut iter = result.rows::<(i32,)>()?; while let Some(read_row) = iter.next().transpose()? { println!("Read a value from row: {}", read_row.0); } diff --git a/docs/source/quickstart/example.md b/docs/source/quickstart/example.md index 52cf01cde5..b5e0009063 100644 --- a/docs/source/quickstart/example.md +++ b/docs/source/quickstart/example.md @@ -44,7 +44,7 @@ async fn main() -> Result<(), Box> { // Query rows from the table and print them let result = session.query("SELECT a FROM ks.extab", &[]).await?; - let mut iter = result.rows_typed::<(i32,)>()?; + let mut iter = result.rows::<(i32,)>()?; while let Some(read_row) = iter.next().transpose()? { println!("Read a value from row: {}", read_row.0); } diff --git a/docs/source/tracing/basic.md b/docs/source/tracing/basic.md index 4ee5bc5737..648334bd02 100644 --- a/docs/source/tracing/basic.md +++ b/docs/source/tracing/basic.md @@ -20,7 +20,7 @@ let mut query: Query = Query::new("INSERT INTO ks.tab (a) VALUES(4)"); query.set_tracing(true); let res: QueryResult = session.query(query, &[]).await?; -let tracing_id: Option = res.tracing_id; +let tracing_id: Option = res.tracing_id(); if let Some(id) = tracing_id { // Query tracing info from system_traces.sessions and system_traces.events @@ -52,7 +52,7 @@ let mut prepared: PreparedStatement = session prepared.set_tracing(true); let res: QueryResult = session.execute(&prepared, &[]).await?; -let tracing_id: Option = res.tracing_id; +let tracing_id: Option = res.tracing_id(); if let Some(id) = tracing_id { // Query tracing info from system_traces.sessions and system_traces.events @@ -83,7 +83,7 @@ batch.append_statement("INSERT INTO ks.tab (a) VALUES(4)"); batch.set_tracing(true); let res: QueryResult = session.batch(&batch, ((),)).await?; -let tracing_id: Option = res.tracing_id; +let tracing_id: Option = res.tracing_id(); if let Some(id) = tracing_id { // Query tracing info from system_traces.sessions and system_traces.events diff --git a/docs/source/tracing/paged.md b/docs/source/tracing/paged.md index e69d4f3361..46e503fa22 100644 --- a/docs/source/tracing/paged.md +++ b/docs/source/tracing/paged.md @@ -13,7 +13,6 @@ If tracing is enabled the row iterator will contain a list of tracing ids for al # use std::error::Error; # async fn check_only_compiles(session: &Session) -> Result<(), Box> { use scylla::query::Query; -use scylla::transport::iterator::RowIterator; use scylla::tracing::TracingInfo; use futures::StreamExt; use uuid::Uuid; @@ -23,7 +22,10 @@ let mut query: Query = Query::new("INSERT INTO ks.tab (a) VALUES(4)"); query.set_tracing(true); // Create a paged query iterator and fetch pages -let mut row_iterator: RowIterator = session.query_iter(query, &[]).await?; +let mut row_iterator = session + .query_iter(query, &[]) + .await? + .into_typed::<(i32,)>(); while let Some(_row) = row_iterator.next().await { // Receive rows } @@ -49,7 +51,6 @@ for id in tracing_ids { # use std::error::Error; # async fn check_only_compiles(session: &Session) -> Result<(), Box> { use scylla::prepared_statement::PreparedStatement; -use scylla::transport::iterator::RowIterator; use scylla::tracing::TracingInfo; use futures::StreamExt; use uuid::Uuid; @@ -63,7 +64,10 @@ let mut prepared: PreparedStatement = session prepared.set_tracing(true); // Create a paged query iterator and fetch pages -let mut row_iterator: RowIterator = session.execute_iter(prepared, &[]).await?; +let mut row_iterator = session + .execute_iter(prepared, &[]) + .await? + .into_typed::<(i32,)>(); while let Some(_row) = row_iterator.next().await { // Receive rows }