pub struct Database { /* private fields */ }
Expand description
A struct that knows how to build Connection
’s, this type does
not do much work until the Database::connect
fn is called.
Implementations§
source§impl Database
impl Database
sourcepub fn open_in_memory() -> Result<Self>
👎Deprecated: Use the new Builder
to construct Database
Available on crate feature core
only.
pub fn open_in_memory() -> Result<Self>
Builder
to construct Database
core
only.Open an in-memory libsql database.
source§impl Database
impl Database
sourcepub async fn open_with_local_sync(
db_path: impl Into<String>,
encryption_config: Option<EncryptionConfig>
) -> Result<Database>
👎Deprecated: Use the new Builder
to construct Database
Available on crate feature replication
only.
pub async fn open_with_local_sync( db_path: impl Into<String>, encryption_config: Option<EncryptionConfig> ) -> Result<Database>
Builder
to construct Database
replication
only.Open a local database file with the ability to sync from snapshots from local filesystem.
sourcepub async fn open_with_local_sync_remote_writes(
db_path: impl Into<String>,
endpoint: String,
auth_token: String,
encryption_config: Option<EncryptionConfig>
) -> Result<Database>
👎Deprecated: Use the new Builder
to construct Database
Available on crate feature replication
only.
pub async fn open_with_local_sync_remote_writes( db_path: impl Into<String>, endpoint: String, auth_token: String, encryption_config: Option<EncryptionConfig> ) -> Result<Database>
Builder
to construct Database
replication
only.Open a local database file with the ability to sync from snapshots from local filesystem and forward writes to the provided endpoint.
sourcepub async fn open_with_local_sync_remote_writes_connector<C>(
db_path: impl Into<String>,
endpoint: String,
auth_token: String,
connector: C,
encryption_config: Option<EncryptionConfig>
) -> Result<Database>
👎Deprecated: Use the new Builder
to construct Database
Available on crate feature replication
only.
pub async fn open_with_local_sync_remote_writes_connector<C>( db_path: impl Into<String>, endpoint: String, auth_token: String, connector: C, encryption_config: Option<EncryptionConfig> ) -> Result<Database>
Builder
to construct Database
replication
only.Open a local database file with the ability to sync from snapshots from local filesystem and forward writes to the provided endpoint and a custom http connector.
sourcepub async fn open_with_remote_sync(
db_path: impl Into<String>,
url: impl Into<String>,
token: impl Into<String>,
encryption_config: Option<EncryptionConfig>
) -> Result<Database>
👎Deprecated: Use the new Builder
to construct Database
Available on crate feature replication
only.
pub async fn open_with_remote_sync( db_path: impl Into<String>, url: impl Into<String>, token: impl Into<String>, encryption_config: Option<EncryptionConfig> ) -> Result<Database>
Builder
to construct Database
replication
only.Open a local database file with the ability to sync from a remote database.
sourcepub async fn open_with_remote_sync_consistent(
db_path: impl Into<String>,
url: impl Into<String>,
token: impl Into<String>,
encryption_config: Option<EncryptionConfig>
) -> Result<Database>
👎Deprecated: Use the new Builder
to construct Database
Available on crate feature replication
only.
pub async fn open_with_remote_sync_consistent( db_path: impl Into<String>, url: impl Into<String>, token: impl Into<String>, encryption_config: Option<EncryptionConfig> ) -> Result<Database>
Builder
to construct Database
replication
only.Open a local database file with the ability to sync from a remote database in consistent mode.
Consistent mode means that when a write happens it will not complete until that write is visible in the local db.
sourcepub async fn open_with_remote_sync_connector<C>(
db_path: impl Into<String>,
url: impl Into<String>,
token: impl Into<String>,
connector: C,
read_your_writes: bool,
encryption_config: Option<EncryptionConfig>
) -> Result<Database>
👎Deprecated: Use the new Builder
to construct Database
Available on crate feature replication
only.
pub async fn open_with_remote_sync_connector<C>( db_path: impl Into<String>, url: impl Into<String>, token: impl Into<String>, connector: C, read_your_writes: bool, encryption_config: Option<EncryptionConfig> ) -> Result<Database>
Builder
to construct Database
replication
only.Connect an embedded replica to a remote primary with a custom http connector.
sourcepub async fn sync(&self) -> Result<Option<FrameNo>>
Available on crate feature replication
only.
pub async fn sync(&self) -> Result<Option<FrameNo>>
replication
only.Sync database from remote, and returns the committed frame_no after syncing, if applicable.
sourcepub async fn sync_frames(&self, frames: Frames) -> Result<Option<FrameNo>>
Available on crate feature replication
only.
pub async fn sync_frames(&self, frames: Frames) -> Result<Option<FrameNo>>
replication
only.Apply a set of frames to the database and returns the committed frame_no after syncing, if applicable.
sourcepub async fn flush_replicator(&self) -> Result<Option<FrameNo>>
Available on crate feature replication
only.
pub async fn flush_replicator(&self) -> Result<Option<FrameNo>>
replication
only.Force buffered replication frames to be applied, and return the current commit frame_no if applicable.
sourcepub async fn replication_index(&self) -> Result<Option<FrameNo>>
Available on crate feature replication
only.
pub async fn replication_index(&self) -> Result<Option<FrameNo>>
replication
only.Returns the database currently committed replication index
source§impl Database
impl Database
sourcepub fn open_remote(
url: impl Into<String>,
auth_token: impl Into<String>
) -> Result<Self>
👎Deprecated: Use the new Builder
to construct Database
Available on crate feature remote
only.
pub fn open_remote( url: impl Into<String>, auth_token: impl Into<String> ) -> Result<Self>
Builder
to construct Database
remote
only.Open a remote based HTTP database using libsql’s hrana protocol.
sourcepub fn open_remote_with_connector<C>(
url: impl Into<String>,
auth_token: impl Into<String>,
connector: C
) -> Result<Self>
👎Deprecated: Use the new Builder
to construct Database
Available on crate feature remote
only.
pub fn open_remote_with_connector<C>( url: impl Into<String>, auth_token: impl Into<String>, connector: C ) -> Result<Self>
Builder
to construct Database
remote
only.Connect to a remote libsql using libsql’s hrana protocol with a custom connector.
source§impl Database
impl Database
sourcepub fn connect(&self) -> Result<Connection>
pub fn connect(&self) -> Result<Connection>
Connect to the database this can mean a few things depending on how it was constructed:
- When constructed with
open
/open_with_flags
/open_in_memory
this will call into the libsql C ffi and create a connection to the libsql database. - When constructed with
open_remote
and friends it will not call any C ffi and will lazily create a HTTP connection to the provided endpoint. - When constructed with
open_with_remote_sync_
and friends it will attempt to perform a handshake with the remote server and will attempt to replicate the remote database locally.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Database
impl !RefUnwindSafe for Database
impl Send for Database
impl Sync for Database
impl Unpin for Database
impl !UnwindSafe for Database
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