Struct fast_walker::WalkPlan

source ·
pub struct WalkPlan {
    pub check_list: Vec<PathBuf>,
    pub follow_symlinks: bool,
    pub depth_first: bool,
    pub threads: usize,
    pub reject_when: fn(_: &Path, _: usize) -> bool,
    pub ignore_when: fn(_: OsString) -> bool,
    pub finish_when: fn(_: &WalkItem) -> bool,
}

Fields§

§check_list: Vec<PathBuf>

Initial paths to search

§follow_symlinks: bool

Follow symlinks

§depth_first: bool

Depth first search or breadth first search

§threads: usize

Number of threads to use

§reject_when: fn(_: &Path, _: usize) -> bool

Check if a directory should be rejected

§ignore_when: fn(_: OsString) -> bool§finish_when: fn(_: &WalkItem) -> bool

Stop if a item matches the condition

Implementations§

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) -> Selfwhere 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(_: &Path, _: usize) -> bool) -> Self

Reject directories if it matches the condition

Examples
  • ignore hidden directories
let plan = WalkPlan::new(".").reject_if(|path, _| path.starts_with("."));
source

pub fn ignore_if(self, f: fn(_: OsString) -> 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 Default for WalkPlan

source§

fn default() -> Self

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

impl<'i> IntoIterator for &'i WalkPlan

§

type Item = WalkItem

The type of the elements being iterated over.
§

type IntoIter = WalkSearcher

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.