pub struct WalkPlan {
pub check_list: Vec<PathBuf>,
pub follow_symlinks: bool,
pub depth_first: bool,
pub capacity: usize,
pub threads: usize,
pub reject_when: fn(&WalkItem) -> bool,
pub ignore_when: fn(&WalkItem) -> bool,
pub finish_when: fn(&WalkItem) -> bool,
}
Expand description
Start a directory walk plan
Fields§
§check_list: Vec<PathBuf>
Initial paths to search
follow_symlinks: bool
Follow symlinks
depth_first: bool
Depth first search or breadth first search
capacity: usize
Max number of items in the buffer
threads: usize
Number of threads to use
reject_when: fn(&WalkItem) -> bool
Check if a directory should be rejected
ignore_when: fn(&WalkItem) -> bool
Ignore a file if it matches the condition
finish_when: fn(&WalkItem) -> bool
Stop if a item matches the condition
Implementations§
Source§impl WalkPlan
impl WalkPlan
Sourcepub fn breadth_first_search(self) -> Self
pub fn breadth_first_search(self) -> Self
Search all subdirectories with breadth first
Sourcepub fn depth_first_search(self) -> Self
pub fn depth_first_search(self) -> Self
Search all subdirectories with depth first
Sourcepub fn with_threads(self, threads: usize) -> Self
pub fn with_threads(self, threads: usize) -> Self
Search with threads
Sourcepub fn reject_if(self, f: fn(&WalkItem) -> bool) -> Self
pub fn reject_if(self, f: fn(&WalkItem) -> bool) -> Self
Reject directories if it matches the condition
§Examples
- ignore hidden directories
let plan = WalkPlan::new(".").reject_if(|item| item.path.starts_with("."));
Sourcepub fn ignore_if(self, f: fn(&WalkItem) -> bool) -> Self
pub fn ignore_if(self, f: fn(&WalkItem) -> bool) -> Self
Ignore files if it’s name matches the condition
Notice that it does not ignore directories whose name matches the condition
§Examples
- ignore non-ascii files
let plan = WalkPlan::new(".").ignore_if(|path| !path.is_ascii());
pub fn finish_if(self, f: fn(&WalkItem) -> bool) -> Self
Trait Implementations§
Source§impl<'i> IntoIterator for &'i WalkPlan
impl<'i> IntoIterator for &'i WalkPlan
Auto Trait Implementations§
impl Freeze for WalkPlan
impl RefUnwindSafe for WalkPlan
impl Send for WalkPlan
impl Sync for WalkPlan
impl Unpin for WalkPlan
impl UnwindSafe for WalkPlan
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
Mutably borrows from an owned value. Read more