Struct WalkPlan

Source
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

Source

pub fn ancestors(&self) -> AncestorWalker<'_>

Source§

impl WalkPlan

Source

pub fn new<P: AsRef<Path>>(path: P) -> Self

Create a new plan with initial path

Source

pub fn roots<I>(roots: I) -> Self
where I: IntoIterator, I::Item: AsRef<Path>,

Create a new plan with initial paths

Search all subdirectories with breadth first

Search all subdirectories with depth first

Source

pub fn with_threads(self, threads: usize) -> Self

Search with threads

Source

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("."));
Source

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());
Source

pub fn finish_if(self, f: fn(&WalkItem) -> bool) -> Self

Trait Implementations§

Source§

impl Clone for WalkPlan

Source§

fn clone(&self) -> WalkPlan

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for WalkPlan

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'i> IntoIterator for &'i WalkPlan

Source§

type Item = Result<WalkItem, WalkError>

The type of the elements being iterated over.
Source§

type IntoIter = LinearWalker<'i>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.