pub struct IncludeExclude { /* private fields */ }Expand description
An rsync-style include/exclude filter.
Rules are processed in order. The first matching rule determines whether the path is included or excluded. If no rule matches, the path is considered to have no explicit ruling (NoMatch).
§Examples
use kaish_glob::{IncludeExclude, FilterResult};
use std::path::Path;
let mut filter = IncludeExclude::new();
filter.include("*.rs");
filter.exclude("*_test.rs");
// Note: order matters! First match wins.
// In this case, *.rs matches first, so test files ARE included.Implementations§
Source§impl IncludeExclude
impl IncludeExclude
Sourcepub fn new() -> IncludeExclude
pub fn new() -> IncludeExclude
Create an empty filter set.
Sourcepub fn include(&mut self, pattern: &str)
pub fn include(&mut self, pattern: &str)
Add an include pattern.
Paths matching this pattern will be included (if checked before any exclude pattern matches).
Sourcepub fn exclude(&mut self, pattern: &str)
pub fn exclude(&mut self, pattern: &str)
Add an exclude pattern.
Paths matching this pattern will be excluded (if checked before any include pattern matches).
Sourcepub fn check(&self, path: &Path) -> FilterResult
pub fn check(&self, path: &Path) -> FilterResult
Check a path against the filter rules.
Returns the first matching rule’s action, or NoMatch if no rules match.
Sourcepub fn excludes_entry(
&self,
relative: &Path,
name: Option<&Path>,
is_dir: bool,
) -> bool
pub fn excludes_entry( &self, relative: &Path, name: Option<&Path>, is_dir: bool, ) -> bool
Decide whether a walk entry is filtered out.
relative is the walk-relative path and name the basename (patterns
like *_test.rs are written against filenames); the first
representation that matches any rule decides. When include rules
exist, a file matching none of them is excluded — but a directory
never is, so traversal can still reach included files below it.
Exclude rules apply to directories too (pruning the subtree).
Sourcepub fn has_includes(&self) -> bool
pub fn has_includes(&self) -> bool
Whether any include rules are present.
Trait Implementations§
Source§impl Clone for IncludeExclude
impl Clone for IncludeExclude
Source§fn clone(&self) -> IncludeExclude
fn clone(&self) -> IncludeExclude
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for IncludeExclude
impl Debug for IncludeExclude
Source§impl Default for IncludeExclude
impl Default for IncludeExclude
Source§fn default() -> IncludeExclude
fn default() -> IncludeExclude
Auto Trait Implementations§
impl Freeze for IncludeExclude
impl RefUnwindSafe for IncludeExclude
impl Send for IncludeExclude
impl Sync for IncludeExclude
impl Unpin for IncludeExclude
impl UnsafeUnpin for IncludeExclude
impl UnwindSafe for IncludeExclude
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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> ⓘ
impl<T> OrderedSeq<'_, T> for Twhere
T: Clone,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
Source§impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
Source§fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned
fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned
WrappingSpan::make_wrapped to wrap an AST node in a span.