pub struct SemanticIndex { /* private fields */ }Expand description
The semantic index — stores embeddings for all symbols in a project
Implementations§
Source§impl SemanticIndex
impl SemanticIndex
pub fn new(project_root: PathBuf, dimension: usize) -> Self
Sourcepub fn entry_count(&self) -> usize
pub fn entry_count(&self) -> usize
Number of embedded symbol entries.
Sourcepub fn indexed_file_count(&self) -> usize
pub fn indexed_file_count(&self) -> usize
Number of files currently tracked by the semantic index.
Sourcepub fn status_label(&self) -> &'static str
pub fn status_label(&self) -> &'static str
Human-readable status label for the index.
Sourcepub fn build<F>(
project_root: &Path,
files: &[PathBuf],
embed_fn: &mut F,
max_batch_size: usize,
) -> Result<Self, String>
pub fn build<F>( project_root: &Path, files: &[PathBuf], embed_fn: &mut F, max_batch_size: usize, ) -> Result<Self, String>
Build the semantic index from a set of files using the provided embedding function.
embed_fn takes a batch of texts and returns a batch of embedding vectors.
Sourcepub fn build_with_progress<F, P>(
project_root: &Path,
files: &[PathBuf],
embed_fn: &mut F,
max_batch_size: usize,
progress: &mut P,
) -> Result<Self, String>
pub fn build_with_progress<F, P>( project_root: &Path, files: &[PathBuf], embed_fn: &mut F, max_batch_size: usize, progress: &mut P, ) -> Result<Self, String>
Build the semantic index and report embedding progress using entry counts.
Sourcepub fn refresh_stale_files<F, P>(
&mut self,
project_root: &Path,
current_files: &[PathBuf],
embed_fn: &mut F,
max_batch_size: usize,
progress: &mut P,
) -> Result<RefreshSummary, String>
pub fn refresh_stale_files<F, P>( &mut self, project_root: &Path, current_files: &[PathBuf], embed_fn: &mut F, max_batch_size: usize, progress: &mut P, ) -> Result<RefreshSummary, String>
Incrementally refresh entries for changed/new files only, preserving cached embeddings for unchanged files. Used when loading the index from disk and finding that a small fraction of files have moved on, deleted, or appeared.
Returns RefreshSummary describing what changed. On success, self is
mutated in place and remains a valid index.
current_files is the full set of files the project considers indexable
(typically walk_project_files(...)). Files in the cache that are no
longer in this set are treated as deleted.
Sourcepub fn refresh_invalidated_files<F, P>(
&mut self,
project_root: &Path,
paths: &[PathBuf],
embed_fn: &mut F,
max_batch_size: usize,
max_files: usize,
progress: &mut P,
) -> Result<InvalidatedFilesRefresh, String>
pub fn refresh_invalidated_files<F, P>( &mut self, project_root: &Path, paths: &[PathBuf], embed_fn: &mut F, max_batch_size: usize, max_files: usize, progress: &mut P, ) -> Result<InvalidatedFilesRefresh, String>
Refresh exactly the files invalidated by the live watcher, without
treating the provided path list as the whole project. This is the
watcher-side counterpart to refresh_stale_files: it drops any stale
entries for the requested paths from this in-memory index, re-extracts
whatever still exists on disk, embeds those chunks, and returns the
delta needed for another in-memory index to apply the same update.
pub fn apply_refresh_update( &mut self, added_entries: Vec<EmbeddingEntry>, updated_metadata: Vec<(PathBuf, FileFreshness)>, completed_paths: &[PathBuf], )
Sourcepub fn search(&self, query_vector: &[f32], top_k: usize) -> Vec<SemanticResult>
pub fn search(&self, query_vector: &[f32], top_k: usize) -> Vec<SemanticResult>
Search the index with a query embedding, returning top-K results sorted by relevance
Sourcepub fn is_file_stale(&self, file: &Path) -> bool
pub fn is_file_stale(&self, file: &Path) -> bool
Check if a file needs re-indexing based on mtime/size
Sourcepub fn remove_file(&mut self, file: &Path)
pub fn remove_file(&mut self, file: &Path)
Remove entries for a specific file
pub fn invalidate_file(&mut self, file: &Path)
pub fn fingerprint(&self) -> Option<&SemanticIndexFingerprint>
pub fn backend_label(&self) -> Option<&str>
pub fn model_label(&self) -> Option<&str>
pub fn set_fingerprint(&mut self, fingerprint: SemanticIndexFingerprint)
Sourcepub fn write_to_disk(&self, storage_dir: &Path, project_key: &str)
pub fn write_to_disk(&self, storage_dir: &Path, project_key: &str)
Write the semantic index to disk using atomic temp+rename pattern
Trait Implementations§
Source§impl Clone for SemanticIndex
impl Clone for SemanticIndex
Source§fn clone(&self) -> SemanticIndex
fn clone(&self) -> SemanticIndex
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SemanticIndex
impl RefUnwindSafe for SemanticIndex
impl Send for SemanticIndex
impl Sync for SemanticIndex
impl Unpin for SemanticIndex
impl UnsafeUnpin for SemanticIndex
impl UnwindSafe for SemanticIndex
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for 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