pub enum FileType {
Regular,
Directory,
Symlink,
}Expand description
An enum with a variant for each file type.
match file_type {
FileType::Regular => {},
FileType::Directory => {},
FileType::Symlink => {},
FileType::BlockDevice => {}, // unix only
FileType::CharDevice => {}, // unix only
FileType::Fifo => {}, // unix only
FileType::Socket => {}, // unix only
}Variants§
Regular
A regular file.
Directory
A directory, folder of files.
Symlink
A symbolic link, points to another path.
Implementations§
Source§impl FileType
impl FileType
Sourcepub fn read_at(path: impl AsRef<Path>) -> Result<Self>
pub fn read_at(path: impl AsRef<Path>) -> Result<Self>
Reads a FileType from a path.
This function follows symlinks, so it can never return a FileType::Symlink.
§Errors
- Path does not exist, or
- Current user lacks permissions to read
fs::Metadataofpath.
Sourcepub fn symlink_read_at(path: impl AsRef<Path>) -> Result<Self>
pub fn symlink_read_at(path: impl AsRef<Path>) -> Result<Self>
Reads a FileType from a path, considers symlinks.
This function does not follow symlinks, therefore, FileType::Symlink can be returned, if
you don’t want that, see FileType::read_at.
§Errors
- Path does not exist, or
- Current user lacks permissions to read
fs::Metadataofpath.
Sourcepub fn is_regular(&self) -> bool
pub fn is_regular(&self) -> bool
Returns true if is a FileType::Regular.
Sourcepub fn is_directory(&self) -> bool
pub fn is_directory(&self) -> bool
Returns true if is a FileType::Directory.
Sourcepub fn is_symlink(&self) -> bool
pub fn is_symlink(&self) -> bool
Returns true if is a FileType::Symlink.
Trait Implementations§
Source§impl Ord for FileType
impl Ord for FileType
Source§impl PartialOrd for FileType
impl PartialOrd for FileType
impl Copy for FileType
impl Eq for FileType
impl StructuralPartialEq for FileType
Auto Trait Implementations§
impl Freeze for FileType
impl RefUnwindSafe for FileType
impl Send for FileType
impl Sync for FileType
impl Unpin for FileType
impl UnwindSafe for FileType
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more