Skip to main content

vtcode_indexer/file_search/
types.rs

1use serde::{Deserialize, Serialize};
2use std::num::NonZero;
3use std::sync::Arc;
4use std::sync::atomic::AtomicBool;
5
6/// A single file match result.
7///
8/// Fields:
9/// - `score`: Relevance score from fuzzy matching (higher is better)
10/// - `path`: Path relative to the search directory
11/// - `match_type`: Whether the match is a file or directory
12/// - `indices`: Optional character positions for highlighting matched characters
13#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
14#[serde(rename_all = "lowercase")]
15pub enum MatchType {
16    File,
17    Directory,
18}
19
20#[derive(Debug, Clone, Serialize, Deserialize)]
21pub struct FileMatch {
22    pub score: u32,
23    pub path: String,
24    pub match_type: MatchType,
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub indices: Option<Vec<u32>>,
27}
28
29/// Complete search results with total match count.
30#[derive(Debug)]
31pub struct FileSearchResults {
32    pub matches: Vec<FileMatch>,
33    pub total_match_count: usize,
34}
35
36/// Configuration for file search operations.
37pub struct FileSearchConfig {
38    pub pattern_text: String,
39    pub limit: NonZero<usize>,
40    pub search_directory: std::path::PathBuf,
41    pub exclude: Vec<String>,
42    pub threads: NonZero<usize>,
43    pub cancel_flag: Arc<AtomicBool>,
44    pub compute_indices: bool,
45    pub respect_gitignore: bool,
46}