1use std::fmt;
2
3#[cfg(feature = "notify")]
5pub mod filekind {
6 pub use notify_types::event::{
7 AccessKind, AccessMode, CreateKind, DataChange, EventKind as FileEventKind, MetadataKind,
8 ModifyKind, RemoveKind, RenameMode,
9 };
10}
11
12#[cfg(not(feature = "notify"))]
14pub mod filekind {
15 pub use crate::sans_notify::{
16 AccessKind, AccessMode, CreateKind, DataChange, EventKind as FileEventKind, MetadataKind,
17 ModifyKind, RemoveKind, RenameMode,
18 };
19}
20
21#[derive(Clone, Copy, Debug, Eq, PartialEq)]
26#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
27#[cfg_attr(feature = "serde", serde(rename_all = "kebab-case"))]
28pub enum FileType {
29 File,
31
32 Dir,
34
35 Symlink,
37
38 Other,
40}
41
42impl From<std::fs::FileType> for FileType {
43 fn from(ft: std::fs::FileType) -> Self {
44 if ft.is_file() {
45 Self::File
46 } else if ft.is_dir() {
47 Self::Dir
48 } else if ft.is_symlink() {
49 Self::Symlink
50 } else {
51 Self::Other
52 }
53 }
54}
55
56impl fmt::Display for FileType {
57 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
58 match self {
59 Self::File => write!(f, "file"),
60 Self::Dir => write!(f, "dir"),
61 Self::Symlink => write!(f, "symlink"),
62 Self::Other => write!(f, "other"),
63 }
64 }
65}