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 run_maintenance(&self) -> SqliteResult<()>
pub fn run_maintenance(&self) -> SqliteResult<()>
Run periodic database maintenance.
Call after bulk operations (scan, trash empty, reindex).
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 check_integrity(&self) -> SqliteResult<bool>
pub fn check_integrity(&self) -> SqliteResult<bool>
Run integrity check on the database.
Returns Ok(true) if database is healthy, Ok(false) if corrupt.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Database
impl !RefUnwindSafe for Database
impl Send for Database
impl !Sync for Database
impl Unpin for Database
impl UnsafeUnpin 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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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