Trait rsfs::DirEntry [] [src]

pub trait DirEntry: Debug {
    type Metadata: Metadata;
    type FileType: FileType;
    fn path(&self) -> PathBuf;
    fn metadata(&self) -> Result<Self::Metadata>;
    fn file_type(&self) -> Result<Self::FileType>;
    fn file_name(&self) -> OsString;
}

Entries returned by the iterator returned from read_dir.

DirEntry represents an entry inside a directory on a filesystem that can be inspected to learn about the entry.

Associated Types

The Metadata type in the same module implementing this trait.

The FileType type in the same module implementing this trait.

Required Methods

Returns the full path to the file or directory this entry represents.

Examples

use rsfs::*;
use rsfs::mem::FS;
let fs = FS::new();

for entry in fs.read_dir(".")? {
    let entry = entry?;
    println!("{:?}", entry.path());
}

This prints output like:

"./foo.txt"
"./README.md"

Returns metadata for the file this entry represents.

Examples

use rsfs::*;
use rsfs::mem::FS;
let fs = FS::new();

for entry in fs.read_dir(".")? {
    let entry = entry?;
    println!("{:?}: {:?}", entry.path(), entry.metadata()?.permissions());
}

Returns the file type for what this entry points at.

Examples

use rsfs::*;
use rsfs::mem::FS;
let fs = FS::new();

for entry in fs.read_dir(".")? {
    let entry = entry?;
    println!("{:?}: {:?}", entry.path(), entry.file_type()?);
}

Returns the base name of the file or directory this entry represents.

Examples

use rsfs::*;
use rsfs::mem::FS;
let fs = FS::new();

for entry in fs.read_dir(".")? {
    println!("{:?}", entry?.file_name());
}

Implementors