Struct r2d2_sqlite::SqliteConnectionManager
source · pub struct SqliteConnectionManager { /* private fields */ }
Expand description
An r2d2::ManageConnection
for rusqlite::Connection
s.
Implementations§
source§impl SqliteConnectionManager
impl SqliteConnectionManager
sourcepub fn file<P: AsRef<Path>>(path: P) -> Self
pub fn file<P: AsRef<Path>>(path: P) -> Self
Creates a new SqliteConnectionManager
from file.
See rusqlite::Connection::open
sourcepub fn with_flags(self, flags: OpenFlags) -> Self
pub fn with_flags(self, flags: OpenFlags) -> Self
Converts SqliteConnectionManager
into one that sets OpenFlags upon
connection creation.
See rustqlite::OpenFlags
for a list of available flags.
sourcepub fn with_init<F>(self, init: F) -> Self
pub fn with_init<F>(self, init: F) -> Self
Converts SqliteConnectionManager
into one that calls an initialization
function upon connection creation. Could be used to set PRAGMAs, for
example.
§Example
Make a SqliteConnectionManager
that sets the foreign_keys
pragma to
true for every connection.
let manager = SqliteConnectionManager::file("app.db")
.with_init(|c| c.execute_batch("PRAGMA foreign_keys=1;"));
Trait Implementations§
source§impl Debug for SqliteConnectionManager
impl Debug for SqliteConnectionManager
source§impl ManageConnection for SqliteConnectionManager
impl ManageConnection for SqliteConnectionManager
§type Connection = Connection
type Connection = Connection
The connection type this manager deals with.
source§fn is_valid(&self, conn: &mut Connection) -> Result<(), Error>
fn is_valid(&self, conn: &mut Connection) -> Result<(), Error>
Determines if the connection is still connected to the database. Read more
source§fn has_broken(&self, _: &mut Connection) -> bool
fn has_broken(&self, _: &mut Connection) -> bool
Quickly determines if the connection is no longer usable. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for SqliteConnectionManager
impl Send for SqliteConnectionManager
impl Sync for SqliteConnectionManager
impl Unpin for SqliteConnectionManager
impl !UnwindSafe for SqliteConnectionManager
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
Mutably borrows from an owned value. Read more