From ab84ad75629b0a4124221023ca91411d2cd62a32 Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Tue, 25 Mar 2025 12:46:49 +1300 Subject: Restructure program This commit also includes changes to devices according to the latest devices specification, in particular the math and system devices. --- src/types/entry_type.rs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/types/entry_type.rs (limited to 'src/types/entry_type.rs') diff --git a/src/types/entry_type.rs b/src/types/entry_type.rs new file mode 100644 index 0000000..6a9ac2d --- /dev/null +++ b/src/types/entry_type.rs @@ -0,0 +1,37 @@ +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 { + 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 , + } + } +} -- cgit v1.2.3-70-g09d2