Builder is the entry point for opening a Turso database in Rust. Configure it with optional feature flags and call .build().await to get a Database.
Builder::new_local(path)
Creates a Builder that will open the SQLite database at path. If the file does not exist it will be created.
Path to the database file, or
":memory:" for an in-memory database.Builder
builder.build().await
Opens the database and returns a Database. This is async because Turso may need to perform I/O during database initialization (for example, reading WAL frames).
Result<Database>
Optional configuration methods
All configuration methods takeself and return Self, so they can be chained:
.experimental_encryption(enabled)
Enables the experimental at-rest encryption feature.
Pass
true to enable encryption.Builder
.with_encryption(opts)
Provides an EncryptionOpts value containing the cipher name and hex-encoded key. Implicitly enables encryption.
Encryption configuration.
Builder
.experimental_attach(enabled)
Enables the ATTACH DATABASE SQL command.
Returns Builder
.experimental_custom_types(enabled)
Enables custom column type handling.
Returns Builder
.experimental_index_method(enabled)
Enables user-defined index methods.
Returns Builder
.experimental_materialized_views(enabled)
Enables experimental materialized view support.
Returns Builder
.with_io(vfs)
Overrides the I/O backend. Supported values depend on the target platform.
VFS identifier string.
Builder
The Database type
After calling .build() you hold a Database. It is Clone and cheap to share across tasks — internally it is an Arc.
db.connect().