Trait rsfs::FileType [] [src]

pub trait FileType: Copy + Clone + PartialEq + Eq + Hash + Debug {
    fn is_dir(&self) -> bool;
    fn is_file(&self) -> bool;
    fn is_symlink(&self) -> bool;
}

Returned from Metadata::file_type, this trait represents the type of a file.

Required Methods

Returns whether this file type is a directory.

Examples

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

let metadata = fs.metadata("foo.txt")?;
let file_type = metadata.file_type();

assert_eq!(file_type.is_dir(), false);

Returns whether this file type is a file.

Examples

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

let metadata = fs.metadata("foo.txt")?;
let file_type = metadata.file_type();

assert_eq!(file_type.is_file(), true);

Returns whether this file type is a symlink.

This will only ever be true if the underlying Metadata type is retrieved with GenFSs symlink_metadata method.

Examples

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

let metadata = fs.metadata("foo.txt")?;
let file_type = metadata.file_type();

assert_eq!(file_type.is_symlink(), false);

Implementors