pub struct IndexManager {
pub schema_version: u32,
/* private fields */
}Expand description
Manages the SQLite persistence layer.
Owns one write Connection (used by the writer task) and exposes
read_connection() to open additional per-thread read-only connections.
Fields§
§schema_version: u32Current schema version after migration.
Implementations§
Source§impl IndexManager
impl IndexManager
Sourcepub fn open(path: &str) -> Result<Self, TuiError>
pub fn open(path: &str) -> Result<Self, TuiError>
Open (or create) the SQLite index at path with WAL mode.
Uses SQLITE_OPEN_NO_MUTEX — thread safety is handled by Rust’s
ownership model (Req 19.9). Runs schema migrations on every open
(Req 19.4).
Sourcepub fn open_in_memory() -> Result<Self, TuiError>
pub fn open_in_memory() -> Result<Self, TuiError>
Open an in-memory database — useful for tests and as a fallback when the on-disk file is corrupt or inaccessible (Req 19.5).
Sourcepub fn migrate(&self) -> Result<u32, TuiError>
pub fn migrate(&self) -> Result<u32, TuiError>
Run pending schema migrations sequentially, preserving existing data.
Detects the current version from schema_meta (0 if the table doesn’t
yet exist), applies each migration whose target version is higher, and
updates schema_version afterward. Each migration runs inside its own
SAVEPOINT so a failure leaves the database at a clean prior version
rather than in an unknown intermediate state (Req 19.4).
Sourcepub fn read_connection(&self) -> Result<Connection, TuiError>
pub fn read_connection(&self) -> Result<Connection, TuiError>
Open a fresh read-only Connection for use in a caller thread.
Each call returns an independent Connection instance, satisfying
the requirement that every thread or task gets its own connection
(Req 19.8, 19.9).
In-memory managers share the write connection for reads (the in-memory database is not accessible from a second connection object).
Sourcepub fn write_conn(&self) -> &Connection
pub fn write_conn(&self) -> &Connection
Borrow the write connection for direct use (e.g. from tests or the writer task before the channel is set up).
Sourcepub fn is_scan_stale(&self, workspace_path: &str, fs_mtime: i64) -> bool
pub fn is_scan_stale(&self, workspace_path: &str, fs_mtime: i64) -> bool
Returns true if the cached scan for workspace_path is older than
fs_mtime (Unix seconds), meaning a re-scan is needed.
Returns true when there is no cached entry (first scan).
Sourcepub fn load_cached_scan_paths(&self) -> Vec<String>
pub fn load_cached_scan_paths(&self) -> Vec<String>
Return all workspace paths that have cached scan entries.
Sourcepub fn load_drift_history(
&self,
) -> Vec<(String, String, String, Option<String>)>
pub fn load_drift_history( &self, ) -> Vec<(String, String, String, Option<String>)>
Load all drift-history rows as
(workspace_path, asset_id, drift_type, resolved_at) tuples, ordered by
id. resolved_at is None for still-active drift.
Sourcepub fn load_coverage_scores(&self) -> Vec<(String, f64)>
pub fn load_coverage_scores(&self) -> Vec<(String, f64)>
Load cached per-workspace coverage scores as (workspace_path, score)
tuples, ordered by workspace path.
Auto Trait Implementations§
impl !Freeze for IndexManager
impl !RefUnwindSafe for IndexManager
impl !Sync for IndexManager
impl !UnwindSafe for IndexManager
impl Send for IndexManager
impl Unpin for IndexManager
impl UnsafeUnpin for IndexManager
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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> ⓘ
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> ⓘ
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