Skip to main content

RepositoryMatcher

Struct RepositoryMatcher 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn root(&self) -> &Path

Source

pub fn sources(&self) -> &[IgnoreSourceEvidence]

Source

pub fn warnings(&self) -> &[ScanWarning]

Source

pub const fn portable(&self) -> bool

Trait Implementations§

Source§

impl Debug for RepositoryMatcher

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.