pub struct SemanticIndex { /* private fields */ }Expand description
The semantic indexing pipeline.
Orchestrates directory walking, AST-aware chunking, embedding, and
vector storage. VFS providers hold an instance of this struct and
delegate index, status, and search calls to it.
§Thread safety
SemanticIndex is Send + Sync and may be shared across async tasks via
Arc<SemanticIndex>.
Implementations§
Source§impl SemanticIndex
impl SemanticIndex
Sourcepub fn new(
embeddings: Arc<dyn Embeddings>,
reranker: Option<Arc<dyn Reranker>>,
store_factory: StoreFactory,
config: IndexConfig,
event_tx: Option<Sender<IndexEvent>>,
) -> Self
pub fn new( embeddings: Arc<dyn Embeddings>, reranker: Option<Arc<dyn Reranker>>, store_factory: StoreFactory, config: IndexConfig, event_tx: Option<Sender<IndexEvent>>, ) -> Self
Create a new SemanticIndex with the given dependencies.
embeddings— embedding model used to vectorise chunks.reranker— optional cross-encoder for result reranking.store_factory— factory that produces aVectorStorefor a cache path.config— pipeline configuration (chunk sizes, cache directory).event_tx— optional channel for streamingIndexEvents to a caller.
Sourcepub async fn index(
&self,
path: &Path,
opts: &IndexOptions,
) -> Result<IndexHandle, VfsError>
pub async fn index( &self, path: &Path, opts: &IndexOptions, ) -> Result<IndexHandle, VfsError>
Start indexing path asynchronously. Returns immediately with an IndexHandle.
If opts.force is false and a valid cache exists for this path, the
index is considered fresh and no work is performed.
§Errors
VfsError::IndexDenied—pathresolves to the filesystem root.VfsError::Io—pathcannot be canonicalised or the store factory fails.
Sourcepub async fn status(&self, index_id: &str) -> Result<IndexStatus, VfsError>
pub async fn status(&self, index_id: &str) -> Result<IndexStatus, VfsError>
Check the status of an indexing operation by its index_id.
§Errors
Returns VfsError::NotFound if index_id is unknown.
Sourcepub async fn search(
&self,
path: &Path,
query: &str,
opts: &SemanticSearchOptions,
) -> Result<Vec<SemanticSearchResult>, VfsError>
pub async fn search( &self, path: &Path, query: &str, opts: &SemanticSearchOptions, ) -> Result<Vec<SemanticSearchResult>, VfsError>
Semantic search across indexed content for path.
§Errors
VfsError::IndexNotReady— the index is still building or has never been started.VfsError::Io— store factory or similarity search fails.
Auto Trait Implementations§
impl !RefUnwindSafe for SemanticIndex
impl !UnwindSafe for SemanticIndex
impl Freeze for SemanticIndex
impl Send for SemanticIndex
impl Sync for SemanticIndex
impl Unpin for SemanticIndex
impl UnsafeUnpin 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
Mutably borrows from an owned value. Read more