pub struct Builder<T = ()> { /* private fields */ }Expand description
A builder for Database. This struct can be used to build
all variants of Database. These variants include:
new_local/Localwhich means aDatabasethat is just a local libsql database it does no networking and does not connect to any remote database.new_remote_replica/RemoteReplicacreates an embedded replica database that will be able to sync from the remote url and delegate writes to the remote primary.new_local_replica/LocalReplicacreates an embedded replica similar to the remote version except you must useDatabase::sync_framesto sync with the remote. This version also includes the ability to delegate writes to a remote primary.new_remote/Remotecreates a database that does not create anything locally but will instead run all queries on the remote database. This is essentially the pure HTTP api.
§Note
Embedded replica’s require a clean database (no database file) or a previously synced database or else it will throw an error to prevent any misuse. To work around this error a user can delete the database and let it resync and create the wal_index metadata file.
Implementations§
source§impl Builder<()>
impl Builder<()>
sourcepub fn new_local(path: impl AsRef<Path>) -> Builder<Local>
Available on crate feature core only.
pub fn new_local(path: impl AsRef<Path>) -> Builder<Local>
core only.Create a new local database.
sourcepub fn new_remote_replica(
path: impl AsRef<Path>,
url: String,
auth_token: String
) -> Builder<RemoteReplica>
Available on crate feature replication only.
pub fn new_remote_replica( path: impl AsRef<Path>, url: String, auth_token: String ) -> Builder<RemoteReplica>
replication only.Create a new remote embedded replica.
sourcepub fn new_local_replica(path: impl AsRef<Path>) -> Builder<LocalReplica>
Available on crate feature replication only.
pub fn new_local_replica(path: impl AsRef<Path>) -> Builder<LocalReplica>
replication only.Create a new local replica.
sourcepub fn new_remote(url: String, auth_token: String) -> Builder<Remote>
Available on crate feature remote only.
pub fn new_remote(url: String, auth_token: String) -> Builder<Remote>
remote only.Create a new remote database.
source§impl Builder<Local>
impl Builder<Local>
sourcepub fn flags(self, flags: OpenFlags) -> Builder<Local>
Available on crate feature core only.
pub fn flags(self, flags: OpenFlags) -> Builder<Local>
core only.Set [OpenFlags] for this database.
sourcepub fn encryption_config(
self,
encryption_config: EncryptionConfig
) -> Builder<Local>
Available on crate feature core only.
pub fn encryption_config( self, encryption_config: EncryptionConfig ) -> Builder<Local>
core only.Set an encryption config that will encrypt the local database.
source§impl Builder<RemoteReplica>
impl Builder<RemoteReplica>
sourcepub fn connector<C>(self, connector: C) -> Builder<RemoteReplica>
Available on crate feature replication only.
pub fn connector<C>(self, connector: C) -> Builder<RemoteReplica>
replication only.Provide a custom http connector that will be used to create http connections.
sourcepub fn encryption_config(
self,
encryption_config: EncryptionConfig
) -> Builder<RemoteReplica>
Available on crate feature replication only.
pub fn encryption_config( self, encryption_config: EncryptionConfig ) -> Builder<RemoteReplica>
replication only.Set an encryption key that will encrypt the local database.
sourcepub fn read_your_writes(self, read_your_writes: bool) -> Builder<RemoteReplica>
Available on crate feature replication only.
pub fn read_your_writes(self, read_your_writes: bool) -> Builder<RemoteReplica>
replication only.Set weather you want writes to be visible locally before the write query returns. This
means that you will be able to read your own writes if this is set to true.
§Default
This defaults to true.
sourcepub fn sync_interval(self, duration: Duration) -> Builder<RemoteReplica>
Available on crate feature replication only.
pub fn sync_interval(self, duration: Duration) -> Builder<RemoteReplica>
replication only.Set the duration at which the replicator will automatically call sync in the
background. The sync will continue for the duration that the resulted Database
type is alive for, once it is dropped the background task will get dropped and stop.
pub fn http_request_callback<F>(self, f: F) -> Builder<RemoteReplica>
replication only.source§impl Builder<LocalReplica>
impl Builder<LocalReplica>
Auto Trait Implementations§
impl<T> RefUnwindSafe for Builder<T>where
T: RefUnwindSafe,
impl<T> Send for Builder<T>where
T: Send,
impl<T> Sync for Builder<T>where
T: Sync,
impl<T> Unpin for Builder<T>where
T: Unpin,
impl<T> UnwindSafe for Builder<T>where
T: UnwindSafe,
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
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request