pub struct RepositoryMatcher { /* private fields */ }Expand description
A reusable, lazily cached repository ignore matcher.
Paths may be absolute or relative to the configured scan root. Directory rule files are loaded once and cached, which makes repeated incremental checks cheap without walking the repository again.
Implementations§
Source§impl RepositoryMatcher
impl RepositoryMatcher
Sourcepub fn new(root: impl AsRef<Path>) -> Result<Self>
pub fn new(root: impl AsRef<Path>) -> Result<Self>
Builds a matcher with the scanner’s reproducible default policy.
§Errors
Returns an error when the root cannot be resolved or inspected.
Sourcepub fn with_options(
root: impl AsRef<Path>,
options: &ScanOptions,
) -> Result<Self>
pub fn with_options( root: impl AsRef<Path>, options: &ScanOptions, ) -> Result<Self>
Builds a matcher from scanner selection options.
§Errors
Returns an error for an invalid root or, under ErrorPolicy::Abort,
when a configured ignore source cannot be read.
Sourcepub fn matched(
&mut self,
path: impl AsRef<Path>,
is_directory: bool,
) -> Result<RepositoryMatch>
pub fn matched( &mut self, path: impl AsRef<Path>, is_directory: bool, ) -> Result<RepositoryMatch>
Returns the winning typed decision from overrides, ignore rules, and the optional hidden-file filter.
§Errors
Returns an error when the path escapes the matcher root or a required
rule file cannot be read under ErrorPolicy::Abort.
Sourcepub fn is_ignored(
&mut self,
path: impl AsRef<Path>,
is_directory: bool,
) -> Result<bool>
pub fn is_ignored( &mut self, path: impl AsRef<Path>, is_directory: bool, ) -> Result<bool>
Returns whether a path is excluded by the effective selection policy.
§Errors
Returns an error under the same conditions as Self::matched.
Sourcepub fn prepare_directory(&mut self, directory: impl AsRef<Path>) -> Result<()>
pub fn prepare_directory(&mut self, directory: impl AsRef<Path>) -> Result<()>
Preloads a directory’s rules for subsequent child checks.
§Errors
Returns an error under the same conditions as Self::is_ignored.
Sourcepub fn refresh(&mut self) -> Result<bool>
pub fn refresh(&mut self) -> Result<bool>
Reloads ignore inputs while preserving the configured matcher policy.
Returns true when effective selection inputs changed.
§Errors
Returns an error under the same conditions as Self::with_options.