Turso Serverless Driver for Rust
A Rust driver for Turso Cloud that speaks the SQL over HTTP protocol. Designed for serverless and edge environments: no persistent connections, no WebSockets, just HTTP requests.
The API mirrors the embedded turso
driver, so the same application code can run against a local database or
Turso Cloud.
Usage
use Builder;
async
For a database encrypted with a customer-managed key, pass the
base64-encoded key with Builder::with_remote_encryption_key.
For short-lived tokens, Builder::with_auth_token_fn takes an async
callback invoked before every HTTP request, so the token can be rotated
(e.g. refreshed from a secrets manager) without rebuilding the database
handle:
# async
Interactive transactions span multiple HTTP requests; the server keeps the connection state alive between them:
# async
Conformance tests
The conformance
crate tests the driver and the wire
protocol against a live database. Point it at a Turso Cloud instance:
$ export TURSO_DATABASE_URL=libsql://<your-db>.turso.io
$ export TURSO_AUTH_TOKEN=<your-token>
$ cargo test -p turso_serverless_conformance
The tests skip themselves when the environment variables are not set.
There are two suites:
tests/driver.rs— exercises the public driver API: queries, parameter binding, prepared statements, transactions, error mapping.tests/protocol.rs— exercises the SQL over HTTP protocol directly with raw HTTP requests, asserting the wire behavior specified in PROTOCOL.md: pipelines, batons, batch conditions, cursors, value encodings, and error reporting.