Struct libsql::Database

source ·
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

source

pub fn open_in_memory() -> Result<Self>

👎Deprecated: Use the new Builder to construct Database
Available on crate feature core only.

Open an in-memory libsql database.

source

pub fn open(db_path: impl Into<String>) -> Result<Database>

👎Deprecated: Use the new Builder to construct Database
Available on crate feature core only.

Open a file backed libsql database.

source

pub fn open_with_flags( db_path: impl Into<String>, flags: OpenFlags ) -> Result<Database>

👎Deprecated: Use the new Builder to construct Database
Available on crate feature core only.

Open a file backed libsql database with flags.

source§

impl Database

source

pub 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.

Open a local database file with the ability to sync from snapshots from local filesystem.

source

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>

👎Deprecated: Use the new Builder to construct Database
Available on crate feature replication only.

Open a local database file with the ability to sync from snapshots from local filesystem and forward writes to the provided endpoint.

source

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>
where C: Service<Uri> + Send + Clone + Sync + 'static, C::Response: Socket, C::Future: Send + 'static, C::Error: Into<Box<dyn Error + Send + Sync>>,

👎Deprecated: Use the new Builder to construct Database
Available on crate feature 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.

source

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>

👎Deprecated: Use the new Builder to construct Database
Available on crate feature replication only.

Open a local database file with the ability to sync from a remote database.

source

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>

👎Deprecated: Use the new Builder to construct Database
Available on crate feature 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.

source

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>
where C: Service<Uri> + Send + Clone + Sync + 'static, C::Response: Socket, C::Future: Send + 'static, C::Error: Into<Box<dyn Error + Send + Sync>>,

👎Deprecated: Use the new Builder to construct Database
Available on crate feature replication only.

Connect an embedded replica to a remote primary with a custom http connector.

source

pub async fn sync(&self) -> Result<Option<FrameNo>>

Available on crate feature replication only.

Sync database from remote, and returns the committed frame_no after syncing, if applicable.

source

pub async fn sync_frames(&self, frames: Frames) -> Result<Option<FrameNo>>

Available on crate feature replication only.

Apply a set of frames to the database and returns the committed frame_no after syncing, if applicable.

source

pub async fn flush_replicator(&self) -> Result<Option<FrameNo>>

Available on crate feature replication only.

Force buffered replication frames to be applied, and return the current commit frame_no if applicable.

source

pub async fn replication_index(&self) -> Result<Option<FrameNo>>

Available on crate feature replication only.

Returns the database currently committed replication index

source

pub fn freeze(self) -> Result<Database>

Available on crate feature replication only.

Freeze this embedded replica and convert it into a regular non-embedded replica database.

§Error

Returns FreezeNotSupported if the database is not configured in embedded replica mode.

source§

impl Database

source

pub 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.

Open a remote based HTTP database using libsql’s hrana protocol.

source

pub fn open_remote_with_connector<C>( url: impl Into<String>, auth_token: impl Into<String>, connector: C ) -> Result<Self>
where C: Service<Uri> + Send + Clone + Sync + 'static, C::Response: Socket, C::Future: Send + 'static, C::Error: Into<Box<dyn Error + Send + Sync>>,

👎Deprecated: Use the new Builder to construct Database
Available on crate feature remote only.

Connect to a remote libsql using libsql’s hrana protocol with a custom connector.

source§

impl Database

source

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§

source§

impl Debug for Database

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more