pub struct MaxDepth(/* private fields */);Expand description
Accepts directories up to a certain depth.
The depth 1 means that only the base directory is visited.
Implementations§
Source§impl MaxDepth
impl MaxDepth
Sourcepub fn new(max_depth: NonZeroUsize) -> Self
pub fn new(max_depth: NonZeroUsize) -> Self
Creates a max depth filter.
This filter is dependant on the starting dir, it first retrieves
the depth of the dir (right from the root ancestor) and then
ensures that visited directories does not exceed the given depth
(path to visit ancestor count - dir ancestor count).
You can also use Path::canonicalize to get the absolute path, which will also
produce a higher depth (if it is not already canonical), however, ensure to only pass
the canonicalized version to the visitor, otherwise, their depths will never match.
Sourcepub fn single_depth() -> Self
pub fn single_depth() -> Self
Creates a single depth filter (i.e, only visits files of provided directory).
This filter is dependant on the starting dir, it first retrieves
the depth of the dir (right from the root ancestor) and then
ensures that visited directories does not exceed the given depth
(path to visit ancestor count - dir ancestor count).
You can also use Path::canonicalize to get the absolute path, which will also
produce a higher depth (if it is not already canonical), however, ensure to only pass
the canonicalized version to the visitor, otherwise, their depths will never match.
Trait Implementations§
Source§impl Filter for MaxDepth
impl Filter for MaxDepth
Source§fn filter(&self, base_path: &Path, p: &Path) -> bool
fn filter(&self, base_path: &Path, p: &Path) -> bool
path_to_visit should be visited or not. The base_path is
the initial directory provided to the visitor. Read moreSource§fn should_emit(&self, _: &Path) -> bool
fn should_emit(&self, _: &Path) -> bool
dir should be emitted by the iterator.Source§fn and<B>(self, other: B) -> And<Self, B>
fn and<B>(self, other: B) -> And<Self, B>
other condition.