Skip to main content

IndexManager

Struct IndexManager 

Source
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: u32

Current schema version after migration.

Implementations§

Source§

impl IndexManager

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

pub fn load_cached_scan_paths(&self) -> Vec<String>

Return all workspace paths that have cached scan entries.

Source

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.

Source

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§

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more