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 normalize(&self, path: impl AsRef<Path>) -> Result<PathBuf>
pub fn normalize(&self, path: impl AsRef<Path>) -> Result<PathBuf>
Normalizes a path and returns its lossless root-relative representation.
Relative inputs are interpreted from this matcher’s root. Absolute inputs outside the root and paths containing parent traversal are rejected.
§Errors
Returns an error when the path escapes the configured scan root.
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.
pub fn root(&self) -> &Path
pub fn sources(&self) -> &[IgnoreSourceEvidence]
pub fn warnings(&self) -> &[ScanWarning]
pub const fn portable(&self) -> bool
Trait Implementations§
Source§impl Clone for RepositoryMatcher
impl Clone for RepositoryMatcher
Source§fn clone(&self) -> RepositoryMatcher
fn clone(&self) -> RepositoryMatcher
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more