pub struct Database { /* private fields */ }Expand description
Database handle with thread-safe write connection and ability to spawn read-only connections.
Implementations§
Source§impl Database
impl Database
Sourcepub fn open(path: &Path) -> Result<Self>
pub fn open(path: &Path) -> Result<Self>
Open a database at the specified path, creating it if necessary. Runs migrations and applies performance optimizations.
Sourcepub fn open_in_memory() -> Result<Self>
pub fn open_in_memory() -> Result<Self>
Open an in-memory database for testing.
Sourcepub const fn writer(&self) -> &Arc<Mutex<Connection>>
pub const fn writer(&self) -> &Arc<Mutex<Connection>>
Get the shared writer connection (behind a mutex).
Sourcepub fn new_reader(&self) -> Result<Connection>
pub fn new_reader(&self) -> Result<Connection>
Create a new read-only connection to the same database.
Auto Trait Implementations§
impl Freeze for Database
impl RefUnwindSafe for Database
impl Send for Database
impl Sync for Database
impl Unpin for Database
impl UnwindSafe for Database
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