cap_fs_ext/
file_type_ext.rs1#[cfg(windows)]
2use cap_primitives::fs::_WindowsFileTypeExt;
3
4pub trait FileTypeExt {
6 fn is_block_device(&self) -> bool;
14
15 fn is_char_device(&self) -> bool;
23
24 fn is_fifo(&self) -> bool;
32
33 fn is_socket(&self) -> bool;
41}
42
43#[cfg(not(windows))]
44impl FileTypeExt for std::fs::FileType {
45 #[inline]
46 fn is_block_device(&self) -> bool {
47 std::os::unix::fs::FileTypeExt::is_block_device(self)
48 }
49
50 #[inline]
51 fn is_char_device(&self) -> bool {
52 std::os::unix::fs::FileTypeExt::is_char_device(self)
53 }
54
55 #[inline]
56 fn is_fifo(&self) -> bool {
57 std::os::unix::fs::FileTypeExt::is_fifo(self)
58 }
59
60 #[inline]
61 fn is_socket(&self) -> bool {
62 std::os::unix::fs::FileTypeExt::is_socket(self)
63 }
64}
65
66#[cfg(all(not(windows), any(feature = "std", feature = "async_std")))]
67impl FileTypeExt for cap_primitives::fs::FileType {
68 #[inline]
69 fn is_block_device(&self) -> bool {
70 cap_primitives::fs::FileTypeExt::is_block_device(self)
71 }
72
73 #[inline]
74 fn is_char_device(&self) -> bool {
75 cap_primitives::fs::FileTypeExt::is_char_device(self)
76 }
77
78 #[inline]
79 fn is_fifo(&self) -> bool {
80 cap_primitives::fs::FileTypeExt::is_fifo(self)
81 }
82
83 #[inline]
84 fn is_socket(&self) -> bool {
85 cap_primitives::fs::FileTypeExt::is_socket(self)
86 }
87}
88
89#[cfg(all(windows, any(feature = "std", feature = "async_std")))]
90impl FileTypeExt for cap_primitives::fs::FileType {
91 #[inline]
92 fn is_block_device(&self) -> bool {
93 _WindowsFileTypeExt::is_block_device(self)
94 }
95
96 #[inline]
97 fn is_char_device(&self) -> bool {
98 _WindowsFileTypeExt::is_char_device(self)
99 }
100
101 #[inline]
102 fn is_fifo(&self) -> bool {
103 _WindowsFileTypeExt::is_fifo(self)
104 }
105
106 #[inline]
107 fn is_socket(&self) -> bool {
108 _WindowsFileTypeExt::is_socket(self)
109 }
110}