pub struct ConnectOptions { /* private fields */ }Expand description
The options for opening a Turso database.
use std::time::Duration;
use turso_orm_driver::ConnectOptions;
let opts = ConnectOptions::new("app.db")
.max_connections(4)
.busy_timeout(Duration::from_secs(5))
.foreign_keys(true);
assert_eq!(opts.max_connections_value(), 4);Implementations§
Source§impl ConnectOptions
impl ConnectOptions
Sourcepub fn new(path: impl AsRef<Path>) -> ConnectOptions
pub fn new(path: impl AsRef<Path>) -> ConnectOptions
Opens, or creates, the database file at path; ":memory:" opens
an in-memory database.
Sourcepub fn in_memory() -> ConnectOptions
pub fn in_memory() -> ConnectOptions
Opens a private in-memory database.
Sourcepub fn sync(
path: impl AsRef<Path>,
remote_url: impl Into<String>,
) -> ConnectOptions
Available on crate feature sync only.
pub fn sync( path: impl AsRef<Path>, remote_url: impl Into<String>, ) -> ConnectOptions
sync only.Opens a local replica of a Turso Cloud database.
Sourcepub fn remote(url: impl Into<String>) -> ConnectOptions
Available on crate feature serverless only.
pub fn remote(url: impl Into<String>) -> ConnectOptions
serverless only.Opens a Turso Cloud database over HTTP, without a local file.
Every statement is an HTTP request, so the busy timeout and the MVCC setting do not apply; the pool, the pragmas and the transactions do, since each connection is a server-side session.
Sourcepub fn auth_token(self, token: impl Into<String>) -> ConnectOptions
Available on crate features serverless or sync only.
pub fn auth_token(self, token: impl Into<String>) -> ConnectOptions
serverless or sync only.Sets the bearer token of a remote database or of an embedded replica’s remote; ignored for local sources.
Sourcepub fn remote_encryption_key(self, key: impl Into<String>) -> ConnectOptions
Available on crate feature serverless only.
pub fn remote_encryption_key(self, key: impl Into<String>) -> ConnectOptions
serverless only.Sets the base64 key of a remote database encrypted with a customer-managed key; ignored for other sources.
Sourcepub fn read_only(self, read_only: bool) -> ConnectOptions
pub fn read_only(self, read_only: bool) -> ConnectOptions
Opens the database in read-only mode.
Sourcepub fn encryption(
self,
cipher: impl Into<String>,
hexkey: impl Into<String>,
) -> ConnectOptions
pub fn encryption( self, cipher: impl Into<String>, hexkey: impl Into<String>, ) -> ConnectOptions
Enables encryption at rest — experimental in Turso.
Sourcepub fn experimental(self, experimental: Experimental) -> ConnectOptions
pub fn experimental(self, experimental: Experimental) -> ConnectOptions
Enables experimental engine features.
Sourcepub fn max_connections(self, max: usize) -> ConnectOptions
pub fn max_connections(self, max: usize) -> ConnectOptions
Sets the maximum number of pooled connections (minimum 1, default 8).
Sourcepub fn acquire_timeout(self, timeout: Duration) -> ConnectOptions
pub fn acquire_timeout(self, timeout: Duration) -> ConnectOptions
Sets how long to wait for a free pooled connection (default 30 s).
Sourcepub fn busy_timeout(
self,
timeout: impl Into<Option<Duration>>,
) -> ConnectOptions
pub fn busy_timeout( self, timeout: impl Into<Option<Duration>>, ) -> ConnectOptions
Sets how long a connection waits on a lock before failing with a busy
error (default 5 s); None fails immediately.
Sourcepub fn foreign_keys(self, enabled: bool) -> ConnectOptions
pub fn foreign_keys(self, enabled: bool) -> ConnectOptions
Enforces foreign keys (PRAGMA foreign_keys = ON, default on).
Sourcepub fn mvcc(self, enabled: bool) -> ConnectOptions
pub fn mvcc(self, enabled: bool) -> ConnectOptions
Switches the database to MVCC (PRAGMA journal_mode = 'mvcc'), which
enables BEGIN CONCURRENT and multiple concurrent writers.
Experimental in Turso; conflicts surface at commit as busy errors.
Sourcepub fn pragma(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> ConnectOptions
pub fn pragma( self, name: impl Into<String>, value: impl Into<String>, ) -> ConnectOptions
Runs PRAGMA name = value on every new connection.
Sourcepub fn max_connections_value(&self) -> usize
pub fn max_connections_value(&self) -> usize
The configured pool size.
Sourcepub fn busy_timeout_value(&self) -> Option<Duration>
pub fn busy_timeout_value(&self) -> Option<Duration>
The configured busy timeout.
Sourcepub fn is_in_memory(&self) -> bool
pub fn is_in_memory(&self) -> bool
Whether this points at the in-memory database.
Trait Implementations§
Source§impl Clone for ConnectOptions
impl Clone for ConnectOptions
Source§fn clone(&self) -> ConnectOptions
fn clone(&self) -> ConnectOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ConnectOptions
impl Debug for ConnectOptions
impl Eq for ConnectOptions
Source§impl From<&Path> for ConnectOptions
impl From<&Path> for ConnectOptions
Source§fn from(path: &Path) -> ConnectOptions
fn from(path: &Path) -> ConnectOptions
Source§impl From<&str> for ConnectOptions
impl From<&str> for ConnectOptions
Source§fn from(path: &str) -> ConnectOptions
fn from(path: &str) -> ConnectOptions
Source§impl From<PathBuf> for ConnectOptions
impl From<PathBuf> for ConnectOptions
Source§fn from(path: PathBuf) -> ConnectOptions
fn from(path: PathBuf) -> ConnectOptions
Source§impl From<String> for ConnectOptions
impl From<String> for ConnectOptions
Source§fn from(path: String) -> ConnectOptions
fn from(path: String) -> ConnectOptions
Source§impl PartialEq for ConnectOptions
impl PartialEq for ConnectOptions
impl StructuralPartialEq for ConnectOptions
Auto Trait Implementations§
impl Freeze for ConnectOptions
impl RefUnwindSafe for ConnectOptions
impl Send for ConnectOptions
impl Sync for ConnectOptions
impl Unpin for ConnectOptions
impl UnsafeUnpin for ConnectOptions
impl UnwindSafe for ConnectOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<K, Q> Equivalent<Q> for K
impl<K, Q> Equivalent<Q> for K
Source§fn equivalent(&self, key: &Q) -> bool
fn equivalent(&self, key: &Q) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more