pub struct Connection { /* private fields */ }
Expand description

A handle which allows access to the underlying rusqlite::Connection via Connection::call().

Implementations§

source§

impl Connection

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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

source§

fn clone(&self) -> Connection

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Connection

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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, U> Into<U> for Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.