1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//! Execution layer: connection pool, transactions and typed rows for Turso.
//!
//! This crate is the execution layer of [turso-orm]. It wraps the [`turso`]
//! client in a small connection pool and gives the layers above a uniform
//! way to run a [`Statement`] — on the pooled handle or inside a
//! transaction — and to read the rows back by the Rust type they want. It
//! owns everything that touches a live connection: opening, pooling,
//! per-connection pragmas, transactions and savepoints, statement execution,
//! streaming, value decoding and error classification. It deliberately does
//! not own SQL generation, which is `turso-sql`'s job, nor entity mapping,
//! which is `turso-orm`'s.
//!
//! # Design
//!
//! - The pool hands out connections created with `db.connect()`, one per
//! slot, and never multiplies a slot by cloning a `turso::Connection`:
//! clones share one engine connection and would serialise on it. A
//! connection goes back to the idle list only when it is in autocommit
//! mode, so a transaction that was dropped mid-way can never leak into
//! the next borrower.
//! - A [`Transaction`] pins one pooled connection for its whole life.
//! Nested transactions are `SAVEPOINT`s on that same connection. Because
//! `Drop` cannot await, rolling back a dropped transaction is deferred: a
//! top-level one discards its connection, a nested one records its depth
//! and the rollback runs before the parent's next statement.
//! - Rows keep their storage class and are decoded on access through
//! [`FromValue`], with SQLite-style leniency — integers become booleans,
//! text parses into dates and UUIDs — so the same column can be read as
//! whatever the caller asks for.
//! - `turso::Error` carries only strings for most variants, so
//! [`ErrorKind`] is derived by variant and, for MVCC conflicts, by message.
//!
//! # Example
//!
//! ```no_run
//! use turso_orm_driver::{ConnectOptions, ConnectionTrait, Database};
//! use turso_sql::Statement;
//!
//! # async fn boot() -> Result<(), turso_orm_driver::Error> {
//! let db = Database::connect(ConnectOptions::new("app.db")).await?;
//! db.execute_unprepared("CREATE TABLE IF NOT EXISTS t (id INTEGER PRIMARY KEY, n TEXT)").await?;
//! let row = db.query_one(Statement::from_string("SELECT COUNT(*) AS n FROM t")).await?;
//! let count: i64 = row.expect("one row").get("n")?;
//! # Ok(())
//! # }
//! ```
//!
//! [turso-orm]: https://github.com/aartintelligent/turso-orm
pub use ;
pub use Database;
pub use FromValue;
pub use ;
pub use ;
pub use RemoteOptions;
pub use SyncOptions;
pub use ;
pub use ;
/// Re-export of the underlying Turso client, so callers can reach engine
/// types such as `turso::Value` without depending on the crate themselves.
pub use turso;
/// Re-export of the SQL layer, so a single dependency gives the whole
/// query language.
pub use turso_sql;
pub use ;