pub struct FilterSettings {
pub includes: Vec<FilterPattern>,
pub excludes: Vec<FilterPattern>,
}Expand description
Settings for filtering files based on include/exclude patterns
Fields§
§includes: Vec<FilterPattern>patterns for files to include (if non-empty, only matching files are included)
excludes: Vec<FilterPattern>patterns for files to exclude
Implementations§
Source§impl FilterSettings
impl FilterSettings
Sourcepub fn has_includes(&self) -> bool
pub fn has_includes(&self) -> bool
Check if this filter has any include patterns
Sourcepub fn should_include_root_item(
&self,
name: &Path,
is_dir: bool,
) -> FilterResult
pub fn should_include_root_item( &self, name: &Path, is_dir: bool, ) -> FilterResult
Determine if a root item (the source itself) should be included based on filter patterns.
This is a specialized version of should_include for root items (the source directory
or file being copied). Anchored patterns (starting with /) are skipped because they
are meant to match paths INSIDE the source root, not the source root itself.
For root files, only non-anchored simple patterns (no /) can directly match the name.
For root directories, they’re always traversed if include patterns exist (to find
matching content inside).
For example, pattern /bar on source foo/ should match foo/bar, not filter out foo.
Sourcepub fn should_include(&self, relative_path: &Path, is_dir: bool) -> FilterResult
pub fn should_include(&self, relative_path: &Path, is_dir: bool) -> FilterResult
Determine if a path should be included based on filter patterns
§Precedence
- If only excludes: include everything except matches
- If only includes: include only matches (exclude everything else by default)
- If both: excludes take priority (excludes checked first, then includes)
§Directory handling
Directories are traversed when include patterns exist if they could potentially contain
matching files. For non-anchored patterns (like *.txt), all directories are traversed.
For anchored patterns (like /bar), only directories matching the pattern prefix are traversed.
Sourcepub fn directly_matches_include(
&self,
relative_path: &Path,
is_dir: bool,
) -> bool
pub fn directly_matches_include( &self, relative_path: &Path, is_dir: bool, ) -> bool
Check if a path directly matches any include pattern (not just could_contain_matches). Used to determine if an empty directory should be kept.
Returns true if:
- No include patterns exist (everything is directly included)
- At least one include pattern directly matches the path
Returns false if:
- Include patterns exist but none match the path (directory was only traversed)
Sourcepub fn could_contain_matches(
&self,
dir_path: &Path,
pattern: &FilterPattern,
) -> bool
pub fn could_contain_matches( &self, dir_path: &Path, pattern: &FilterPattern, ) -> bool
Check if a directory could potentially contain files matching the pattern
Sourcepub fn from_file(path: &Path) -> Result<Self, Error>
pub fn from_file(path: &Path) -> Result<Self, Error>
Parse filter settings from a file
§File Format
# comments supported
--include *.rs
--include Cargo.toml
--exclude target/
--exclude *.logSourcepub fn parse_content(content: &str) -> Result<Self, Error>
pub fn parse_content(content: &str) -> Result<Self, Error>
Parse filter settings from a string (filter file format)
Trait Implementations§
Source§impl Clone for FilterSettings
impl Clone for FilterSettings
Source§fn clone(&self) -> FilterSettings
fn clone(&self) -> FilterSettings
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FilterSettings
impl Debug for FilterSettings
Source§impl Default for FilterSettings
impl Default for FilterSettings
Source§fn default() -> FilterSettings
fn default() -> FilterSettings
Source§impl<'de> Deserialize<'de> for FilterSettings
impl<'de> Deserialize<'de> for FilterSettings
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Auto Trait Implementations§
impl Freeze for FilterSettings
impl RefUnwindSafe for FilterSettings
impl Send for FilterSettings
impl Sync for FilterSettings
impl Unpin for FilterSettings
impl UnsafeUnpin for FilterSettings
impl UnwindSafe for FilterSettings
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> 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>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request