pub struct Database {
pub conn: Connection,
}Expand description
Database wrapper with path information
Fields§
§conn: ConnectionImplementations§
Source§impl Database
impl Database
Sourcepub fn open_for_drive<P: AsRef<Path>>(
drive_root: P,
) -> Result<Self, DatabaseError>
pub fn open_for_drive<P: AsRef<Path>>( drive_root: P, ) -> Result<Self, DatabaseError>
Sourcepub fn needs_schema(&self) -> SqliteResult<bool>
pub fn needs_schema(&self) -> SqliteResult<bool>
Check if this is a fresh database (needs schema creation)
Sourcepub fn flush_and_close(self)
pub fn flush_and_close(self)
Aggressively flush WAL to the main DB file and consume the connection. Use on drive deselect / app exit so a yanked USB drive doesn’t leave unwritten data behind. TRUNCATE is the strict mode (vs PASSIVE) — it both checkpoints AND empties the WAL file.
Sourcepub fn checkpoint_truncate(&self)
pub fn checkpoint_truncate(&self)
Flush WAL into the main DB file while the connection stays open.
Called on app exit (the shared connection is behind an Arc, so it
cannot be consumed like flush_and_close) so a drive yanked or a
catalog copied right after the window closes cannot lose recent
commits that were still sitting in the WAL. Best-effort: a
checkpoint blocked by readers is skipped rather than awaited.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Database
impl !RefUnwindSafe for Database
impl !Sync for Database
impl !UnwindSafe for Database
impl Send for Database
impl Unpin for Database
impl UnsafeUnpin 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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more