diff options
Diffstat (limited to 'src/devices/file/entry.rs')
-rw-r--r-- | src/devices/file/entry.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/devices/file/entry.rs b/src/devices/file/entry.rs new file mode 100644 index 0000000..a91ae82 --- /dev/null +++ b/src/devices/file/entry.rs @@ -0,0 +1,36 @@ +use crate::*; + +use std::cmp::Ordering; + +pub enum Entry { + File(BufferedFile), + Directory(DirectoryListing), +} + +#[derive(Copy, Clone, PartialEq, Eq)] +pub enum EntryType { + File, + Directory, +} + +impl PartialOrd for EntryType { + fn partial_cmp(&self, other: &Self) -> Option<Ordering> { + match (self, other) { + (EntryType::Directory, EntryType::Directory) => Some(Ordering::Equal ), + (EntryType::Directory, EntryType::File ) => Some(Ordering::Less ), + (EntryType::File, EntryType::Directory) => Some(Ordering::Greater), + (EntryType::File, EntryType::File ) => Some(Ordering::Equal ), + } + } +} + +impl Ord for EntryType { + fn cmp(&self, other: &Self) -> Ordering { + match (self, other) { + (EntryType::Directory, EntryType::Directory) => Ordering::Equal , + (EntryType::Directory, EntryType::File ) => Ordering::Less , + (EntryType::File, EntryType::Directory) => Ordering::Greater, + (EntryType::File, EntryType::File ) => Ordering::Equal , + } + } +} |