Filter

Trait Filter 

Source
pub trait Filter {
    // Required method
    fn filter(&self, base_path: &Path, path_to_visit: &Path) -> bool;

    // Provided methods
    fn should_emit(&self, _: &Path) -> bool { ... }
    fn and<B>(self, other: B) -> And<Self, B>
       where Self: Sized,
             B: Filter { ... }
    fn or<B>(self, other: B) -> Or<Self, B>
       where Self: Sized,
             B: Filter { ... }
    fn not(self) -> Not<Self>
       where Self: Sized { ... }
}

Required Methods§

Source

fn filter(&self, base_path: &Path, path_to_visit: &Path) -> bool

Checks whether path_to_visit should be visited or not. The base_path is the initial directory provided to the visitor.

This filter is called only for directories, if it returns true it means that the directory should be visited, otherwise, it will be skipped.

The directory will be emitted by the iterator regardless of the return value of this function.

Provided Methods§

Source

fn should_emit(&self, _: &Path) -> bool

Checks whether dir should be emitted by the iterator.

Source

fn and<B>(self, other: B) -> And<Self, B>
where Self: Sized, B: Filter,

Creates a filter that only accepts both this and the other condition.

Source

fn or<B>(self, other: B) -> Or<Self, B>
where Self: Sized, B: Filter,

Creates a filter that accepts this or the other condition.

Source

fn not(self) -> Not<Self>
where Self: Sized,

Creates a filter that negates when this filter accepts.

Implementors§

Source§

impl Filter for Accept

Source§

impl Filter for MaxDepth

Source§

impl<A> Filter for This<A>
where A: Filter,

Source§

impl<F> Filter for Closure<F>
where F: Fn(&Path, &Path) -> bool,

Source§

impl<S> Filter for Extension<S>
where S: AsRef<OsStr>,