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
type Metadata: Metadata
The Metadata
type in the same module implementing this trait.
type FileType: FileType
The FileType
type in the same module implementing this trait.
Required Methods
fn path(&self) -> PathBuf
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"
fn metadata(&self) -> Result<Self::Metadata>
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()); }
fn file_type(&self) -> Result<Self::FileType>
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()?); }
fn file_name(&self) -> OsString
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()); }