Struct async_rusqlite::Connection
source · 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.
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.
Failure
Will return Err if the underlying SQLite open call fails.
sourcepub async fn open_with_flags<P: AsRef<Path>>(
path: P,
flags: OpenFlags
) -> Result<Connection, Error>
pub async fn open_with_flags<P: AsRef<Path>>( path: P, flags: OpenFlags ) -> Result<Connection, Error>
Open a new connection to a SQLite database.
Database Connection for a description of valid flag combinations.
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_with_flags_and_vfs<P: AsRef<Path>>(
path: P,
flags: OpenFlags,
vfs: &str
) -> Result<Connection, Error>
pub async fn open_with_flags_and_vfs<P: AsRef<Path>>( path: P, flags: OpenFlags, vfs: &str ) -> Result<Connection, Error>
Open a new connection to a SQLite database using the specific flags and vfs name.
Database Connection for a description of valid flag combinations.
Failure
Will return Err if either path or vfs cannot be converted to a
C-compatible string or if the underlying SQLite open call fails.
sourcepub async fn open_in_memory_with_flags(
flags: OpenFlags
) -> Result<Connection, Error>
pub async fn open_in_memory_with_flags( flags: OpenFlags ) -> Result<Connection, Error>
Open a new connection to an in-memory SQLite database.
Database Connection for a description of valid flag combinations.
Failure
Will return Err if the underlying SQLite open call fails.
sourcepub async fn open_in_memory_with_flags_and_vfs(
flags: OpenFlags,
vfs: &str
) -> Result<Connection, Error>
pub async fn open_in_memory_with_flags_and_vfs( flags: OpenFlags, vfs: &str ) -> Result<Connection, Error>
Open a new connection to an in-memory SQLite database using the specific flags and vfs name.
Database Connection for a description of valid flag combinations.
Failure
Will return Err if vfs cannot be converted to a C-compatible
string or if the underlying SQLite open call fails.
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