Trait DirEntry

Source
pub trait DirEntry {
    type Path: ?Sized;
    type PathOwned;
    type Metadata;
    type FileType;
    type Error;

    // Required methods
    fn path(&self) -> Self::PathOwned;
    fn metadata(&self) -> Result<Self::Metadata, Self::Error>;
    fn file_type(&self) -> Result<Self::FileType, Self::Error>;
    fn file_name(&self) -> &Self::Path;
}
Expand description

Entries returned by the Dir iterator.

An instance of DirEntry represents an entry inside of a directory on the filesystem. Each entry can be inspected via methods to learn about the full path or possibly other metadata through per-platform extension traits.

Required Associated Types§

Source

type Path: ?Sized

The borrowed path slice that represents a relative or absolute path on the filesystem.

Source

type PathOwned

The owned path that represents a relative or absolute path on the filesystem.

Source

type Metadata

The type that represents a files metadata on the filesystem.

Source

type FileType

The type that represents the union of all possible filetypes.

Source

type Error

The type that represents the set of all errors that can occur during reading or writing.

Required Methods§

Source

fn path(&self) -> Self::PathOwned

Returns the full path to the file that this entry represents.

The full path is created by joining the original path to read_dir with the filename of this entry.

Source

fn metadata(&self) -> Result<Self::Metadata, Self::Error>

Return the metadata for the file that this entry points at.

This function will not traverse symlinks if this entry points at a symlink.

Source

fn file_type(&self) -> Result<Self::FileType, Self::Error>

Return the file type for the file that this entry points at.

This function will not traverse symlinks if this entry points at a symlink.

Source

fn file_name(&self) -> &Self::Path

Returns the bare file name of this directory entry without any other leading path component.

Implementors§