pub struct Db(pub Mutex<Connection>);Tuple Fields§
§0: Mutex<Connection>Implementations§
Source§impl Db
impl Db
Sourcepub fn open_path(path: &Path) -> Result<(Self, Option<Degraded>)>
pub fn open_path(path: &Path) -> Result<(Self, Option<Degraded>)>
Open the on-disk database at path, recovering from corruption rather than degrading permanently.
A single corrupt file would otherwise be terminal: opening fails on every launch. An
unreadable file is quarantined (original bytes and sidecars kept, see recovery_policy) and
a fresh persistent database is created at the same path; the returned Some(Degraded) has
quarantined set so the UI can tell the user where the old file went (persistence_status).
Err when the database cannot be opened at all (locked or unwritable folder, a database
written by a newer incompatible build, an unfinished earlier quarantine). The caller reports
it and exits; the session never continues on a store that does not persist.
pub fn list_recent(&self, limit: i64) -> Result<Vec<FileEntry>>
pub fn clear_recent(&self) -> Result<()>
pub fn is_pinned(&self, path: &str) -> Result<bool>
pub fn toggle_pin( &self, path: &str, display_name: &str, format: &str, ) -> Result<bool>
Sourcepub fn toggle_pin_dir(&self, path: &str, display_name: &str) -> Result<bool>
pub fn toggle_pin_dir(&self, path: &str, display_name: &str) -> Result<bool>
Pin/unpin a directory. Directories have no document format, so format stores the
literal “dir” — keeping the NOT NULL column honest and mirroring what list_pins
reports for these rows (kind distinguishes them either way).
Sourcepub fn list_pins(&self) -> Result<Vec<PinEntry>>
pub fn list_pins(&self) -> Result<Vec<PinEntry>>
All pins in stored pin order (the sort_order sequence toggle_pin* assigns).
The renderer groups rows into pinned folders then files — the DB does not
re-sort, so pins stay in the order the user created them.
pub fn record_recent( &self, path: &str, display_name: &str, format: &str, ) -> Result<()>
pub fn save_view_state( &self, path: &str, last_view: &str, view_meta: Option<&str>, display_name: &str, format: &str, ) -> Result<()>
Sourcepub fn view_state(&self, path: &str) -> Result<ViewState>
pub fn view_state(&self, path: &str) -> Result<ViewState>
Restored view state is advisory: a document must still open when it can’t be read, so this
falls back to the default rather than propagating. The caller (read_document) uses ?, so
returning an error here would turn a transient database lock into a failure to open a file the
database has no say over. A missing row is the ordinary case for a first-time open and stays
silent; anything else is a real fault and is logged instead of vanishing.
Sourcepub fn save_session(&self, tabs: &[(&str, bool)]) -> Result<()>
pub fn save_session(&self, tabs: &[(&str, bool)]) -> Result<()>
Replace the saved session atomically. The clear-then-insert pair must not run in autocommit: a failure partway through the loop would otherwise leave the previous session already deleted and the new one half-written, so the next launch would restore a truncated set of tabs (or none) with nothing reporting that anything was lost.
pub fn load_session(&self) -> Result<Vec<(String, bool)>>
pub fn clear_session(&self) -> Result<()>
Sourcepub fn purge_user_paths(&self) -> Result<()>
pub fn purge_user_paths(&self) -> Result<()>
Privacy purge: delete every stored document path (recents with their view state, the saved
session tabs, and pins) in one transaction, then overwrite freed pages (secure_delete) and
truncate the WAL so no path string survives in the database file or its sidecar.