Execution, decoding, and transactions
Query builders do not depend on a database client. Query::compile produces a CompiledQuery containing SQL and Vec<Value>. An Executor passes those values to a concrete driver.
Executor contract
A custom runtime only implements this boundary. It does not need to understand SelectQuery or other builder type states.
Database facade
Database<D, E> stores the dialect and executor while separating failure stages:
Decoding
Row exposes driver-neutral Value instances by position. FromValue handles scalars, while FromRow handles scalars and tuples. Integer conversion is checked and never truncates overflow.
Scoped transactions
SQLite and PostgreSQL executors both provide scoped transaction APIs. Success commits and an operation error rolls back:
Manual transactions use TransactionManager::begin, Transaction::commit, and Transaction::rollback. Reserve them for infrastructure that must carry a transaction across functions.
Cancellation safety
- SQLite keeps the shared connection gate until rollback cleanup completes, so another clone cannot execute early.
- A cancelled SQLite savepoint completes
ROLLBACK TO SAVEPOINTandRELEASE SAVEPOINTfirst. - PostgreSQL detaches an incomplete transaction connection from the pool before asynchronous rollback.
- If the Tokio runtime has ended, closing the PostgreSQL connection lets the server roll back.
These guarantees prevent an open transaction from reaching a later request. They do not replay application operations automatically.