pub struct Find {
pub description_glob: ToolDescription,
pub description_grep: ToolDescription,
/* private fields */
}Expand description
Shared-state wrapper for file-search tool operations.
Holds configuration for both [glob] and [grep] searches. Fields
that are not set via builder methods remain None, deferring to each
tool’s internal default.
Fields§
§description_glob: ToolDescriptionMCP Tool description for glob.
description_grep: ToolDescriptionMCP Tool description for grep.
Implementations§
Source§impl Find
impl Find
Sourcepub fn file_type(self, ft: impl Into<String>) -> Self
pub fn file_type(self, ft: impl Into<String>) -> Self
Restrict glob results to a filesystem kind ("file", "dir", "symlink").
Sourcepub const fn recursive(self, v: bool) -> Self
pub const fn recursive(self, v: bool) -> Self
Search subdirectories recursively (default: true).
Sourcepub const fn max_results(self, n: u32) -> Self
pub const fn max_results(self, n: u32) -> Self
Maximum number of glob entries to return.
Sourcepub const fn sort_by_mtime(self, v: bool) -> Self
pub const fn sort_by_mtime(self, v: bool) -> Self
Sort glob results by modification time, most recent first.
Sourcepub fn glob_format(self, f: impl Into<String>) -> Self
pub fn glob_format(self, f: impl Into<String>) -> Self
Output layout for glob results ("flat", "grouped", "tree").
Sourcepub fn name_glob(self, g: impl Into<String>) -> Self
pub fn name_glob(self, g: impl Into<String>) -> Self
Restrict grep to files whose names match this glob (e.g. "*.rs").
Sourcepub fn language(self, lang: impl Into<String>) -> Self
pub fn language(self, lang: impl Into<String>) -> Self
Restrict grep to files of a given language (e.g. "rust", "py").
Sourcepub const fn ignore_case(self, v: bool) -> Self
pub const fn ignore_case(self, v: bool) -> Self
Case-insensitive matching.
Sourcepub const fn max_count(self, n: u32) -> Self
pub const fn max_count(self, n: u32) -> Self
Maximum total number of grep matches across all files.
Sourcepub const fn context_before(self, n: u32) -> Self
pub const fn context_before(self, n: u32) -> Self
Lines of context to include before each match.
Sourcepub const fn context_after(self, n: u32) -> Self
pub const fn context_after(self, n: u32) -> Self
Lines of context to include after each match.
Include hidden files / directories (names starting with .).
Sourcepub const fn timeout_ms(self, ms: u32) -> Self
pub const fn timeout_ms(self, ms: u32) -> Self
Abort the search after this many milliseconds.
Sourcepub fn cwd(self, path: impl Into<PathBuf>) -> Self
pub fn cwd(self, path: impl Into<PathBuf>) -> Self
Set the project root directory (used for path-validation guards).
Sourcepub fn allowlist(
self,
paths: impl IntoIterator<Item = impl Into<PathBuf>>,
) -> Self
pub fn allowlist( self, paths: impl IntoIterator<Item = impl Into<PathBuf>>, ) -> Self
Set the explicit path allowlist.
Sourcepub fn blocklist(
self,
paths: impl IntoIterator<Item = impl Into<PathBuf>>,
) -> Self
pub fn blocklist( self, paths: impl IntoIterator<Item = impl Into<PathBuf>>, ) -> Self
Set the explicit path blocklist.
Sourcepub fn add_allowlist_path(&mut self, path: PathBuf)
pub fn add_allowlist_path(&mut self, path: PathBuf)
Add a path to the allowlist (for session-level persistence).
Sourcepub fn remove_allowlist_path(&mut self, path: &Path)
pub fn remove_allowlist_path(&mut self, path: &Path)
Remove a path from the allowlist (for AllowOnce cleanup).
If the path is not in the allowlist, this is a no-op.
Sourcepub fn allowlist_ref(&self) -> Option<&[PathBuf]>
pub fn allowlist_ref(&self) -> Option<&[PathBuf]>
Get the allowlist (read-only reference).
Sourcepub fn blocklist_ref(&self) -> Option<&[PathBuf]>
pub fn blocklist_ref(&self) -> Option<&[PathBuf]>
Get the blocklist (read-only reference).
Sourcepub fn glob(&self, pattern: &str, path: &str) -> Result<GlobOutput, String>
pub fn glob(&self, pattern: &str, path: &str) -> Result<GlobOutput, String>
Find filesystem entries matching a glob pattern.
See [glob] for details.
§Errors
Returns an error when the search path does not exist, the pattern is invalid, or the operation times out.
Sourcepub fn glob_with(
&self,
pattern: &str,
path: Option<String>,
paths: Option<Vec<String>>,
on_match: Option<Arc<GlobMatchCallback>>,
) -> Result<GlobOutput, String>
pub fn glob_with( &self, pattern: &str, path: Option<String>, paths: Option<Vec<String>>, on_match: Option<Arc<GlobMatchCallback>>, ) -> Result<GlobOutput, String>
Like glob, but searches one or more targets in a single
call (paths overrides path; each target is guard-resolved
individually), optionally streaming matches live via on_match.
Each entry in path/paths may be a directory, a literal file, or a
glob (with or without a directory prefix); the effective pattern and
recursion are derived from its shape. Output paths are rebased to the
CWD when they live under it (feature: relative-to-CWD resolution).
§Errors
Returns an error when the search paths are missing, a pattern is invalid, or the operation times out.
Sourcepub fn glob_full(
&self,
pattern: &str,
path: Option<String>,
paths: Option<Vec<String>>,
opts: GlobCallOptions,
on_match: Option<Arc<GlobMatchCallback>>,
) -> Result<GlobOutput, String>
pub fn glob_full( &self, pattern: &str, path: Option<String>, paths: Option<Vec<String>>, opts: GlobCallOptions, on_match: Option<Arc<GlobMatchCallback>>, ) -> Result<GlobOutput, String>
Like glob_with, with the schema-driven call options
bundled in GlobCallOptions: optional file_type ("file",
"dir", "symlink"), hidden and gitignore toggles, format
("flat", "grouped", "tree"), a sort_by_mtime toggle, an optional
timeout_ms, and an optional max_results.
The effective result cap defaults to 200 (mirroring the reference
tool) when neither this call’s max_results nor the builder’s is
set, and the ceiling is fixed: a max_results above 200 is clamped
down, so the caller can only lower the result set. A max_results
of 0 is rejected.
hidden and gitignore default to true unless explicitly disabled
(reference-tool behavior). sort_by_mtime defaults to true —
the most recently modified files surface first. file_type filters
results to one filesystem kind and is an extension over the
reference tool.
§Errors
Returns an error when a search path cannot be resolved, a pattern is
invalid, file_type is unknown, max_results is zero, or the
operation times out.
Sourcepub fn grep(&self, pattern: &str, path: &str) -> Result<GrepOutput, String>
pub fn grep(&self, pattern: &str, path: &str) -> Result<GrepOutput, String>
Search file content for lines matching a regex pattern.
See [grep] for details.
§Errors
Returns an error when the path cannot be resolved, the pattern is an invalid regex, or the operation times out.
Sourcepub fn grep_skipping(
&self,
pattern: &str,
path: &str,
skip: Option<u32>,
) -> Result<GrepOutput, String>
pub fn grep_skipping( &self, pattern: &str, path: &str, skip: Option<u32>, ) -> Result<GrepOutput, String>
Like grep, but pages past the first file window with
skip (files to skip before collecting results). Ignored for
single-file scopes.
Sourcepub fn grep_with(
&self,
pattern: &str,
path: Option<String>,
paths: Option<Vec<String>>,
skip: Option<u32>,
line_range: Option<String>,
) -> Result<GrepOutput, String>
pub fn grep_with( &self, pattern: &str, path: Option<String>, paths: Option<Vec<String>>, skip: Option<u32>, line_range: Option<String>, ) -> Result<GrepOutput, String>
Search one or more targets in a single call, with optional pagination
(skip) and a 1-based inclusive line_range ("start-end").
paths overrides path when present; each target is resolved and
validated individually by the path guard, so the approval shown to the
user is exactly the set of targets the search opens. line_range
requires every target to be a single file.
§Errors
Returns an error when a target cannot be resolved, no target is provided, the pattern is an invalid regex, or the operation times out.
Sourcepub fn grep_with_streaming(
&self,
pattern: &str,
path: Option<String>,
paths: Option<Vec<String>>,
skip: Option<u32>,
line_range: Option<String>,
on_match: Option<Arc<GrepMatchCallback>>,
) -> Result<GrepOutput, String>
pub fn grep_with_streaming( &self, pattern: &str, path: Option<String>, paths: Option<Vec<String>>, skip: Option<u32>, line_range: Option<String>, on_match: Option<Arc<GrepMatchCallback>>, ) -> Result<GrepOutput, String>
Like grep_with, optionally streaming each match
live via on_match (formatted path:line, rebased for multi-target
calls).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Find
impl RefUnwindSafe for Find
impl Send for Find
impl Sync for Find
impl Unpin for Find
impl UnsafeUnpin for Find
impl UnwindSafe for Find
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> 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> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.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 moreSource§impl<T> IntoMaybeUndefined<T> for T
impl<T> IntoMaybeUndefined<T> for T
Source§fn into_maybe_undefined(self) -> MaybeUndefined<T>
fn into_maybe_undefined(self) -> MaybeUndefined<T>
Source§impl<T> IntoOption<T> for T
impl<T> IntoOption<T> for T
Source§fn into_option(self) -> Option<T>
fn into_option(self) -> Option<T>
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.