Skip to main content

Db

Struct Db 

Source
pub struct Db(pub Mutex<Connection>);

Tuple Fields§

§0: Mutex<Connection>

Implementations§

Source§

impl Db

Source

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.

Source

pub fn list_recent(&self, limit: i64) -> Result<Vec<FileEntry>>

Source

pub fn clear_recent(&self) -> Result<()>

Source

pub fn is_pinned(&self, path: &str) -> Result<bool>

Source

pub fn toggle_pin( &self, path: &str, display_name: &str, format: &str, ) -> Result<bool>

Source

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).

Source

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.

Source

pub fn record_recent( &self, path: &str, display_name: &str, format: &str, ) -> Result<()>

Source

pub fn save_view_state( &self, path: &str, last_view: &str, view_meta: Option<&str>, display_name: &str, format: &str, ) -> Result<()>

Source

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.

Source

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.

Source

pub fn load_session(&self) -> Result<Vec<(String, bool)>>

Source

pub fn clear_session(&self) -> Result<()>

Source

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.

Auto Trait Implementations§

§

impl !Freeze for Db

§

impl RefUnwindSafe for Db

§

impl Send for Db

§

impl Sync for Db

§

impl Unpin for Db

§

impl UnsafeUnpin for Db

§

impl UnwindSafe for Db

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.