pub struct DbPool { /* private fields */ }Expand description
Thread-safe SQLite connection pool (single writer via Mutex).
For a web server workload the single-writer approach is acceptable because
SQLite WAL mode allows concurrent readers. All writes are serialised
through the Mutex.
Implementations§
Source§impl DbPool
impl DbPool
Sourcepub fn open(db_path: &Path) -> Result<Self, Error>
pub fn open(db_path: &Path) -> Result<Self, Error>
Open or create the SQLite database at the given path and run migrations.
§Errors
Returns an error if the database cannot be opened or migrations fail.
Sourcepub fn open_in_memory() -> Result<Self, Error>
pub fn open_in_memory() -> Result<Self, Error>
Open an in-memory database (useful for tests).
§Errors
Returns an error if the in-memory database cannot be created.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DbPool
impl RefUnwindSafe for DbPool
impl Send for DbPool
impl Sync for DbPool
impl Unpin for DbPool
impl UnsafeUnpin for DbPool
impl UnwindSafe for DbPool
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