Trait wax::walk::Entry

source ·
pub trait Entry {
    // Required methods
    fn into_path(self) -> PathBuf
       where Self: Sized;
    fn path(&self) -> &Path;
    fn root_relative_paths(&self) -> (&Path, &Path);
    fn metadata(&self) -> Result<Metadata, WalkError>;
    fn file_type(&self) -> FileType;
    fn depth(&self) -> usize;
}
Available on crate feature walk only.
Expand description

Describes a file yielded from a FileIterator.

Required Methods§

source

fn into_path(self) -> PathBufwhere Self: Sized,

Converts the entry into its file path.

source

fn path(&self) -> &Path

Gets the path of the file.

source

fn root_relative_paths(&self) -> (&Path, &Path)

Gets the root and relative paths.

The root path is the path to the walked directory from which the file entry has been read. The relative path is the remainder of the file path of the entry (the path relative to the root directory). Both the root and relative paths may be empty.

The root and relative paths can differ significantly depending on the way a directory is walked, in particular when using a Glob. The following table describes some example paths when using Glob::walk.

Glob ExpressionDirectoryEntry PathRootRelative
**/*.txt/home/user/home/user/notes.txt/home/usernotes.txt
projects/**/src/**/*.rs../projects/fibonacci/src/main.rs.projects/fibonacci/src/main.rs
/var/log/**/*.log./var/log/pacman.log/var/log/pacman.log

See also GlobWalker::root_prefix_paths.

source

fn metadata(&self) -> Result<Metadata, WalkError>

Gets the Metadata of the file.

On some platforms, this requires an additional read from the file system.

source

fn file_type(&self) -> FileType

Gets the type of the file (regular vs. directory).

Prefer this function over metadata if only the file type is needed, as this information is cached.

source

fn depth(&self) -> usize

Gets the depth of the file path from the root.

The root path is the path to the walked directory from which the file entry has been read. Use root_relative_paths to get the root path.

Implementors§