pub struct IndexDb { /* private fields */ }Expand description
SQLite-backed symbol and import index for a single project.
Implementations§
Source§impl IndexDb
impl IndexDb
Sourcepub fn get_fresh_file_by_mtime(
&self,
relative_path: &str,
mtime_ms: i64,
) -> Result<Option<FileRow>>
pub fn get_fresh_file_by_mtime( &self, relative_path: &str, mtime_ms: i64, ) -> Result<Option<FileRow>>
Fast mtime-only freshness check. Avoids content hashing entirely.
Sourcepub fn get_fresh_file(
&self,
relative_path: &str,
mtime_ms: i64,
content_hash: &str,
) -> Result<Option<FileRow>>
pub fn get_fresh_file( &self, relative_path: &str, mtime_ms: i64, content_hash: &str, ) -> Result<Option<FileRow>>
Returns the file row if it exists and is fresh (same mtime and hash).
Sourcepub fn get_file(&self, relative_path: &str) -> Result<Option<FileRow>>
pub fn get_file(&self, relative_path: &str) -> Result<Option<FileRow>>
Returns the file row by path (regardless of freshness).
Sourcepub fn upsert_file(
&self,
relative_path: &str,
mtime_ms: i64,
content_hash: &str,
size_bytes: i64,
language: Option<&str>,
) -> Result<i64>
pub fn upsert_file( &self, relative_path: &str, mtime_ms: i64, content_hash: &str, size_bytes: i64, language: Option<&str>, ) -> Result<i64>
Upsert a file record. Returns the file id. Deletes old symbols/imports on update.
Sourcepub fn delete_file(&self, relative_path: &str) -> Result<()>
pub fn delete_file(&self, relative_path: &str) -> Result<()>
Delete a file and its associated symbols/imports.
Sourcepub fn file_count(&self) -> Result<usize>
pub fn file_count(&self) -> Result<usize>
Count indexed files.
Sourcepub fn all_file_paths(&self) -> Result<Vec<String>>
pub fn all_file_paths(&self) -> Result<Vec<String>>
Return all indexed file paths.
Sourcepub fn files_with_symbol_kinds(&self, kinds: &[&str]) -> Result<Vec<String>>
pub fn files_with_symbol_kinds(&self, kinds: &[&str]) -> Result<Vec<String>>
Return file paths containing symbols of given kinds.
pub fn dir_stats(&self) -> Result<Vec<DirStats>>
Sourcepub fn insert_symbols(
&self,
file_id: i64,
symbols: &[NewSymbol<'_>],
) -> Result<Vec<i64>>
pub fn insert_symbols( &self, file_id: i64, symbols: &[NewSymbol<'_>], ) -> Result<Vec<i64>>
Bulk insert symbols for a file. Returns the inserted symbol ids.
Sourcepub fn find_symbols_by_name(
&self,
name: &str,
file_path: Option<&str>,
exact: bool,
max_results: usize,
) -> Result<Vec<SymbolRow>>
pub fn find_symbols_by_name( &self, name: &str, file_path: Option<&str>, exact: bool, max_results: usize, ) -> Result<Vec<SymbolRow>>
Query symbols by name (exact or substring match).
Sourcepub fn find_symbols_with_path(
&self,
name: &str,
exact: bool,
max_results: usize,
) -> Result<Vec<(SymbolRow, String)>>
pub fn find_symbols_with_path( &self, name: &str, exact: bool, max_results: usize, ) -> Result<Vec<(SymbolRow, String)>>
Query symbols by name with file path resolved via JOIN (no N+1). Returns (SymbolRow, file_path) tuples.
Sourcepub fn get_file_symbols(&self, file_id: i64) -> Result<Vec<SymbolRow>>
pub fn get_file_symbols(&self, file_id: i64) -> Result<Vec<SymbolRow>>
Get all symbols for a file, ordered by start_byte.
Sourcepub fn search_symbols_fts(
&self,
query: &str,
max_results: usize,
) -> Result<Vec<(SymbolRow, String, f64)>>
pub fn search_symbols_fts( &self, query: &str, max_results: usize, ) -> Result<Vec<(SymbolRow, String, f64)>>
Full-text search symbols via FTS5 index. Returns (SymbolRow, file_path, rank). Falls back to LIKE search if FTS5 table doesn’t exist (pre-v4 DB).
Sourcepub fn get_symbols_for_directory(
&self,
prefix: &str,
) -> Result<Vec<(String, Vec<SymbolRow>)>>
pub fn get_symbols_for_directory( &self, prefix: &str, ) -> Result<Vec<(String, Vec<SymbolRow>)>>
Get all symbols for files under a directory prefix in a single JOIN query.
Returns (file_path, Vec
Sourcepub fn all_symbol_names(
&self,
) -> Result<Vec<(String, String, String, i64, String, String)>>
pub fn all_symbol_names( &self, ) -> Result<Vec<(String, String, String, i64, String, String)>>
Return all symbols as (name, kind, file_path, line, signature, name_path).
Sourcepub fn all_symbols_with_bytes(&self) -> Result<Vec<SymbolWithFile>>
pub fn all_symbols_with_bytes(&self) -> Result<Vec<SymbolWithFile>>
Get all symbols with byte offsets and file paths, ordered by file for batch processing.
Sourcepub fn for_each_symbol_with_bytes<F>(&self, callback: F) -> Result<usize>
pub fn for_each_symbol_with_bytes<F>(&self, callback: F) -> Result<usize>
Stream all symbols with bytes via callback — avoids loading entire Vec into memory. Symbols are ordered by file_path then start_byte (same as all_symbols_with_bytes).
Sourcepub fn for_each_file_symbols_with_bytes<F>(&self, callback: F) -> Result<usize>
pub fn for_each_file_symbols_with_bytes<F>(&self, callback: F) -> Result<usize>
Stream symbols grouped by file path via callback — avoids loading the entire symbol table into memory and gives deterministic file-wise order.
Sourcepub fn symbols_for_files(
&self,
file_paths: &[&str],
) -> Result<Vec<SymbolWithFile>>
pub fn symbols_for_files( &self, file_paths: &[&str], ) -> Result<Vec<SymbolWithFile>>
Get symbols with bytes for specific files only (for incremental embedding).
Sourcepub fn get_file_path(&self, file_id: i64) -> Result<Option<String>>
pub fn get_file_path(&self, file_id: i64) -> Result<Option<String>>
Get file path for a file_id.
Sourcepub fn insert_imports(&self, file_id: i64, imports: &[NewImport]) -> Result<()>
pub fn insert_imports(&self, file_id: i64, imports: &[NewImport]) -> Result<()>
Bulk insert imports for a file.
Sourcepub fn get_importers(&self, target_path: &str) -> Result<Vec<String>>
pub fn get_importers(&self, target_path: &str) -> Result<Vec<String>>
Get files that import the given file path (reverse dependencies).
Sourcepub fn get_imports_of(&self, relative_path: &str) -> Result<Vec<String>>
pub fn get_imports_of(&self, relative_path: &str) -> Result<Vec<String>>
Get files that the given file imports (forward dependencies).
Sourcepub fn build_import_graph(
&self,
) -> Result<HashMap<String, (Vec<String>, Vec<String>)>>
pub fn build_import_graph( &self, ) -> Result<HashMap<String, (Vec<String>, Vec<String>)>>
Build the full import graph from the database.
Sourcepub fn insert_calls(&self, file_id: i64, calls: &[NewCall]) -> Result<()>
pub fn insert_calls(&self, file_id: i64, calls: &[NewCall]) -> Result<()>
Bulk insert call edges for a file (clears old edges first).
Sourcepub fn get_callers_cached(
&self,
callee_name: &str,
max_results: usize,
) -> Result<Vec<(String, String, i64)>>
pub fn get_callers_cached( &self, callee_name: &str, max_results: usize, ) -> Result<Vec<(String, String, i64)>>
Find all callers of a function name (from DB cache).
Sourcepub fn get_callees_cached(
&self,
caller_name: &str,
file_path: Option<&str>,
max_results: usize,
) -> Result<Vec<(String, i64)>>
pub fn get_callees_cached( &self, caller_name: &str, file_path: Option<&str>, max_results: usize, ) -> Result<Vec<(String, i64)>>
Find all callees of a function name (from DB cache).
Sourcepub fn has_call_data(&self) -> Result<bool>
pub fn has_call_data(&self) -> Result<bool>
Check if calls table has any data.
Sourcepub fn record_index_failure(
&self,
file_path: &str,
error_type: &str,
error_message: &str,
) -> Result<()>
pub fn record_index_failure( &self, file_path: &str, error_type: &str, error_message: &str, ) -> Result<()>
Record an indexing failure for a file. Updates retry_count on conflict.
Sourcepub fn clear_index_failure(&self, file_path: &str) -> Result<()>
pub fn clear_index_failure(&self, file_path: &str) -> Result<()>
Clear a failure record when a file is successfully indexed.
Sourcepub fn invalidate_fts(&self) -> Result<()>
pub fn invalidate_fts(&self) -> Result<()>
Invalidate FTS index cache so next search triggers a lazy rebuild.
Sourcepub fn index_failure_count(&self) -> Result<usize>
pub fn index_failure_count(&self) -> Result<usize>
Get the number of files with indexing failures.
Sourcepub fn prune_missing_index_failures(&self, project_root: &Path) -> Result<usize>
pub fn prune_missing_index_failures(&self, project_root: &Path) -> Result<usize>
Remove failure records for files that no longer exist on disk.
Sourcepub fn index_failure_summary(
&self,
recent_window_secs: i64,
) -> Result<IndexFailureSummary>
pub fn index_failure_summary( &self, recent_window_secs: i64, ) -> Result<IndexFailureSummary>
Summarize unresolved index failures by recency and persistence.
Source§impl IndexDb
impl IndexDb
Sourcepub fn open(db_path: &Path) -> Result<Self>
pub fn open(db_path: &Path) -> Result<Self>
Open or create the index database at the given path.
Sourcepub fn open_readonly(db_path: &Path) -> Result<Option<Self>>
pub fn open_readonly(db_path: &Path) -> Result<Option<Self>>
Open existing database in read-only mode (no migration, no WAL creation). Returns None if the DB file does not exist.
Sourcepub fn open_memory() -> Result<Self>
pub fn open_memory() -> Result<Self>
Open an in-memory database (for testing).
Sourcepub fn with_transaction<F, T>(&mut self, f: F) -> Result<T>
pub fn with_transaction<F, T>(&mut self, f: F) -> Result<T>
Execute a closure within an RAII transaction. Automatically rolls back on error or panic; commits only on success.
Auto Trait Implementations§
impl !Freeze for IndexDb
impl !RefUnwindSafe for IndexDb
impl Send for IndexDb
impl !Sync for IndexDb
impl Unpin for IndexDb
impl UnsafeUnpin for IndexDb
impl !UnwindSafe for IndexDb
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 moreSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more