pub struct SearchRequest {Show 13 fields
pub pattern: String,
pub root: PathBuf,
pub mode: MatchMode,
pub case: CaseSensitivity,
pub include_globs: Vec<String>,
pub language_globs: Vec<String>,
pub exclude_globs: Vec<String>,
pub max_results: usize,
pub max_per_file: usize,
pub max_file_size: Option<u64>,
pub include_hidden: bool,
pub respect_ignore_files: bool,
pub files_with_matches: bool,
}Expand description
Configuration for a content search.
Fields§
§pattern: StringThe pattern to match.
root: PathBufRoot directory (or file) to search.
mode: MatchModeHow to interpret SearchRequest::pattern.
case: CaseSensitivityWhether matching is case-sensitive.
include_globs: Vec<String>Only report files whose path matches one of these globs.
Matched case-sensitively, mirroring ripgrep’s --glob.
language_globs: Vec<String>Only report files whose path matches one of these globs.
Matched case-insensitively, mirroring ripgrep’s --iglob, which is
what the language filters use so *.RS still matches a Rust file.
exclude_globs: Vec<String>Never report files whose path matches one of these globs.
max_results: usizeMaximum number of matches to report.
max_per_file: usizeMaximum number of matches to report per file.
max_file_size: Option<u64>Skip files larger than this many bytes.
Include files inside hidden directories.
respect_ignore_files: boolHonour .gitignore, .ignore, and .git/exclude while walking.
files_with_matches: boolReport files that contain a match instead of the matching lines.
Implementations§
Source§impl SearchRequest
impl SearchRequest
Sourcepub fn literal(pattern: impl Into<String>, root: impl Into<PathBuf>) -> Self
pub fn literal(pattern: impl Into<String>, root: impl Into<PathBuf>) -> Self
Creates a literal, case-sensitive search request.
Sourcepub fn regex(pattern: impl Into<String>, root: impl Into<PathBuf>) -> Self
pub fn regex(pattern: impl Into<String>, root: impl Into<PathBuf>) -> Self
Creates a regex, case-sensitive search request.
Sourcepub fn with_case(self, case: CaseSensitivity) -> Self
pub fn with_case(self, case: CaseSensitivity) -> Self
Sets the case-sensitivity of the search.
Sourcepub fn with_max_results(self, max_results: usize) -> Self
pub fn with_max_results(self, max_results: usize) -> Self
Sets the maximum number of matches reported overall.
Sourcepub fn with_max_per_file(self, max_per_file: usize) -> Self
pub fn with_max_per_file(self, max_per_file: usize) -> Self
Sets the maximum number of matches reported per file.
Sourcepub fn with_include_glob(self, glob: impl Into<String>) -> Self
pub fn with_include_glob(self, glob: impl Into<String>) -> Self
Adds a glob that candidate file paths must match.
The glob is matched case-sensitively, like ripgrep’s --glob.
Sourcepub fn with_language_glob(self, glob: impl Into<String>) -> Self
pub fn with_language_glob(self, glob: impl Into<String>) -> Self
Adds a glob that candidate file paths must match, case-insensitively.
This mirrors ripgrep’s --iglob, which the language filters use so a
*.RS file still counts as Rust.
Includes hidden files and directories in the walk.
Sourcepub fn with_max_file_size(self, max_file_size: u64) -> Self
pub fn with_max_file_size(self, max_file_size: u64) -> Self
Sets the maximum size of a file that may be scanned.
Sourcepub fn with_files_with_matches(self) -> Self
pub fn with_files_with_matches(self) -> Self
Reports only the files that contain a match, not the matching lines.
Sourcepub fn with_exclude_glob(self, glob: impl Into<String>) -> Self
pub fn with_exclude_glob(self, glob: impl Into<String>) -> Self
Excludes files whose path matches glob.
Exclusions are applied after inclusions, so an excluded file never reaches the scanner even when it also matches an include glob.
Sourcepub fn without_ignore_files(self) -> Self
pub fn without_ignore_files(self) -> Self
Disables ignore-file handling, so every file in the tree is scanned.