pub struct Connection { /* private fields */ }
Expand description
A handle which allows access to the underlying rusqlite::Connection
via Connection::call()
.
Implementations§
Source§impl Connection
impl Connection
Sourcepub async fn open<P: AsRef<Path>>(path: P) -> Result<Connection, Error>
pub async fn open<P: AsRef<Path>>(path: P) -> Result<Connection, Error>
Open a new connection to an SQLite database. If a database does not exist at the
path, one is created. Shorthand for Connection::builder().open(path).await
.
§Failure
Will return Err
if path
cannot be converted to a C-compatible string
or if the underlying SQLite open call fails.
Sourcepub async fn open_in_memory() -> Result<Connection, Error>
pub async fn open_in_memory() -> Result<Connection, Error>
Open a new connection to an in-memory SQLite database. Shorthand for
Connection::builder().open_in_memory().await
.
§Failure
Will return Err
if the underlying SQLite open call fails.
Sourcepub fn builder() -> ConnectionBuilder
pub fn builder() -> ConnectionBuilder
Configure and build a new connection.
Sourcepub async fn close(&self) -> Result<(), Error>
pub async fn close(&self) -> Result<(), Error>
Close the SQLite connection.
This is functionally equivalent to the Drop
implementation for
Connection
except that on failure, it returns the error. Unlike
the rusqlite
version of this method, it does not need to consume
self
.
§Failure
Will return Err
if the underlying SQLite call fails.
Sourcepub async fn call<R, E, F>(&self, f: F) -> Result<R, E>where
R: Send + 'static,
E: Send + 'static + From<AlreadyClosed>,
F: Send + 'static + FnOnce(&mut Connection) -> Result<R, E>,
pub async fn call<R, E, F>(&self, f: F) -> Result<R, E>where
R: Send + 'static,
E: Send + 'static + From<AlreadyClosed>,
F: Send + 'static + FnOnce(&mut Connection) -> Result<R, E>,
Run some arbitrary function against the rusqlite::Connection
and return the result.
§Failure
Will return Err if the connection is closed, or if the provided function returns an error.
The error type must impl From<AlreadyClosed>
to handle this possibility being emitted.
Trait Implementations§
Source§impl Clone for Connection
impl Clone for Connection
Source§fn clone(&self) -> Connection
fn clone(&self) -> Connection
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more