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 should_exclude(&self, path: &Path) -> bool
pub fn should_exclude(&self, path: &Path) -> bool
Check if a path should be filtered out.
Returns true if the path should be excluded (either explicitly excluded or not matching any include patterns when in strict mode).
Trait Implementations§
Source§impl Clone for IncludeExclude
impl Clone for IncludeExclude
Source§fn clone(&self) -> IncludeExclude
fn clone(&self) -> IncludeExclude
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more