Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples: replace query_unpaged for SELECT queries #1069

Merged
merged 6 commits into from
Aug 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
examples/udt: query_unpaged -> query_iter
muzarski committed Aug 28, 2024
commit c0ca401da67bd8cec700a9cb4cc87c777e7d82da
14 changes: 9 additions & 5 deletions examples/user-defined-type.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use anyhow::Result;
use futures::TryStreamExt;
use scylla::macros::FromUserType;
use scylla::{SerializeValue, Session, SessionBuilder};
use std::env;
@@ -49,11 +50,14 @@ async fn main() -> Result<()> {
.await?;

// And read like any normal value
let result = session
.query_unpaged("SELECT my FROM examples_ks.user_defined_type_table", &[])
.await?;
let mut iter = result.rows_typed::<(MyType,)>()?;
while let Some((my_val,)) = iter.next().transpose()? {
let mut iter = session
.query_iter(
"SELECT a, b, c FROM examples_ks.user_defined_type_table",
&[],
)
.await?
.into_typed::<(MyType,)>();
while let Some((my_val,)) = iter.try_next().await? {
println!("{:?}", my_val);
}