pub struct FileIndexer {
AppState: Arc<ApplicationState>,
file_index: Arc<RwLock<FileIndex>>,
index_directory: PathBuf,
file_watcher: Arc<Mutex<Option<RecommendedWatcher>>>,
indexing_semaphore: Arc<Semaphore>,
corruption_detected: Arc<Mutex<bool>>,
}Expand description
File indexer implementation with comprehensive search capabilities
This indexer provides:
- Incremental file watching with real-time updates
- Multi-mode search (literal, regex, fuzzy)
- Symbol extraction for VSCode Outline View
- Language detection for syntax highlighting
- Index corruption detection and recovery
- Parallel indexing with resource limits
Fields§
§AppState: Arc<ApplicationState>Application state
file_index: Arc<RwLock<FileIndex>>File index with metadata and symbols
index_directory: PathBufIndex storage directory
file_watcher: Arc<Mutex<Option<RecommendedWatcher>>>File watcher for incremental updates
indexing_semaphore: Arc<Semaphore>Semaphore for limiting parallel indexing operations
corruption_detected: Arc<Mutex<bool>>Index corruption detection state
Implementations§
Source§impl FileIndexer
impl FileIndexer
Sourcepub async fn new(AppState: Arc<ApplicationState>) -> Result<Self>
pub async fn new(AppState: Arc<ApplicationState>) -> Result<Self>
Create a new file indexer with comprehensive setup
Initializes the indexer with:
- Index directory creation
- Existing index loading or fresh creation
- Index corruption detection
- Service status initialization
Sourcefn ValidateAndExpandPath(path: &str) -> Result<PathBuf>
fn ValidateAndExpandPath(path: &str) -> Result<PathBuf>
Validate and expand path with traversal protection
Sourceasync fn VerifyIndexIntegrity(&self) -> Result<()>
async fn VerifyIndexIntegrity(&self) -> Result<()>
Verify index integrity and detect corruption
Sourcepub async fn IndexDirectory(
&self,
path: String,
patterns: Vec<String>,
) -> Result<IndexResult>
pub async fn IndexDirectory( &self, path: String, patterns: Vec<String>, ) -> Result<IndexResult>
Index a directory with comprehensive validation and parallel processing
Sourcepub async fn SearchFiles(
&self,
query: SearchQuery,
path: Option<String>,
language: Option<String>,
) -> Result<PaginatedSearchResults>
pub async fn SearchFiles( &self, query: SearchQuery, path: Option<String>, language: Option<String>, ) -> Result<PaginatedSearchResults>
Search files with multiple modes
Sourcepub async fn SearchSymbols(
&self,
query: &str,
max_results: u32,
) -> Result<Vec<SymbolInfo>>
pub async fn SearchSymbols( &self, query: &str, max_results: u32, ) -> Result<Vec<SymbolInfo>>
Search symbols across all files (for VSCode Go to Symbol)
Sourcepub async fn GetFileSymbols(
&self,
file_path: &PathBuf,
) -> Result<Vec<SymbolInfo>>
pub async fn GetFileSymbols( &self, file_path: &PathBuf, ) -> Result<Vec<SymbolInfo>>
Get symbols for a specific file (for VSCode Outline View)
Sourcepub async fn GetFileInfo(&self, path: String) -> Result<Option<FileMetadata>>
pub async fn GetFileInfo(&self, path: String) -> Result<Option<FileMetadata>>
Get file information
Sourcepub async fn GetIndexStatistics(&self) -> Result<IndexStatistics>
pub async fn GetIndexStatistics(&self) -> Result<IndexStatistics>
Get index statistics
Sourcepub async fn recover_from_corruption(&self) -> Result<()>
pub async fn recover_from_corruption(&self) -> Result<()>
Recover corrupted index
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FileIndexer
impl !RefUnwindSafe for FileIndexer
impl Send for FileIndexer
impl Sync for FileIndexer
impl Unpin for FileIndexer
impl !UnwindSafe for FileIndexer
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Applies the layer to a service and wraps it in [
Layered].