Trait wax::walk::PathExt

source ·
pub trait PathExt {
    // Required method
    fn walk_with_behavior(&self, behavior: impl Into<WalkBehavior>) -> WalkTree ;

    // Provided method
    fn walk(&self) -> WalkTree  { ... }
}
Available on crate feature walk only.
Expand description

Functions for walking a directory tree at a Path.

Required Methods§

source

fn walk_with_behavior(&self, behavior: impl Into<WalkBehavior>) -> WalkTree

Gets an iterator over files in the directory tree at the path.

This function is the same as PathExt::walk, but it additionally accepts a WalkBehavior that configures how the traversal interacts with symbolic links, the maximum depth from the root, etc.

Examples
use std::path::Path;
use wax::walk::{Entry, LinkBehavior, PathExt};

// Read the target of symbolic links (follow links).
for entry in Path::new("/home").walk_with_behavior(LinkBehavior::ReadTarget) {
    let entry = entry.unwrap();
    println!("{:?}", entry.path());
}

Provided Methods§

source

fn walk(&self) -> WalkTree

Gets an iterator over files in the directory tree at the path.

If the path refers to a regular file, then only its path is yielded by the iterator.

This function uses the default WalkBehavior. To configure the behavior of the traversal, see PathExt::walk_with_behavior.

Examples
use std::path::Path;
use wax::walk::{Entry, PathExt};

for entry in Path::new(".").walk() {
    let entry = entry.unwrap();
    println!("{:?}", entry.path());
}

Implementations on Foreign Types§

source§

impl PathExt for Path

Implementors§