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
source§impl Database
impl Database
sourcepub async fn open_with_local_sync(
db_path: impl Into<String>
) -> Result<Database>
Available on crate feature replication only.
pub async fn open_with_local_sync( db_path: impl Into<String> ) -> Result<Database>
replication only.Open a local database file with the ability to sync from snapshots from local filesystem.
sourcepub async fn open_with_remote_sync(
db_path: impl Into<String>,
url: impl Into<String>,
token: impl Into<String>
) -> Result<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> ) -> Result<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>
) -> Result<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> ) -> Result<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
) -> Result<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 ) -> Result<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>
Available on crate feature remote only.
pub fn open_remote( url: impl Into<String>, auth_token: impl Into<String> ) -> Result<Self>
remote only.Open a remote based HTTP database using libsql’s hrana protocol.
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_memorythis will call into the libsql C ffi and create a connection to the libsql database. - When constructed with
open_remoteand 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.
Auto Trait Implementations§
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