Revert "Merge 'Rust binding improvements' from Pedro Muniz"

This reverts commit bd60cd214c, reversing
changes made to 74e48a3a8f because it
makes limbo_stress hang.
This commit is contained in:
Pekka Enberg
2025-07-03 12:28:10 +03:00
parent 4e5de4b03f
commit ca990e8fd1
10 changed files with 236 additions and 402 deletions

View File

@@ -1,6 +1,3 @@
#![cfg(feature = "futures")]
use futures_util::stream::TryStreamExt;
use turso::Builder;
#[tokio::main]
@@ -9,15 +6,8 @@ async fn main() {
let conn = db.connect().unwrap();
// `query` and other methods, only parse the first query given.
let mut rows = conn.query("select 1; select 1;", ()).await.unwrap();
// Iterate over the rows with the Stream iterator syntax
while let Some(row) = rows.try_next().await.unwrap() {
let val = row.get_value(0).unwrap();
println!("{:?}", val);
}
conn.query("select 1; select 1;", ()).await.unwrap();
// Contrary to `prepare` and `query`, `execute` is not lazy and will execute the query to completion
conn.execute("CREATE TABLE IF NOT EXISTS users (email TEXT)", ())
.await
.unwrap();
@@ -42,20 +32,9 @@ async fn main() {
let mut rows = stmt.query(["foo@example.com"]).await.unwrap();
while let Some(row) = rows.try_next().await.unwrap() {
let value = row.get_value(0).unwrap();
println!("Row: {:?}", value);
}
let row = rows.next().await.unwrap().unwrap();
let rows = stmt.query(["foo@example.com"]).await.unwrap();
let value = row.get_value(0).unwrap();
// As `Rows` implement streams you can easily map over it and apply other transformations you see fit
println!("Using Stream map");
rows.map_ok(|row| row.get_value(0).unwrap())
.try_for_each(|val| {
println!("Row: {:?}", val.as_text().unwrap());
futures_util::future::ready(Ok(()))
})
.await
.unwrap();
println!("Row: {:?}", value);
}