summaryrefslogtreecommitdiff
path: root/src/devices/file/directory_entry.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/file/directory_entry.rs')
-rw-r--r--src/devices/file/directory_entry.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/devices/file/directory_entry.rs b/src/devices/file/directory_entry.rs
new file mode 100644
index 0000000..45de817
--- /dev/null
+++ b/src/devices/file/directory_entry.rs
@@ -0,0 +1,30 @@
+use crate::*;
+
+use std::cmp::Ordering;
+
+#[derive(PartialEq, Eq)]
+pub struct DirectoryChild {
+ pub byte_path: Vec<u8>,
+ pub entry_type: EntryType,
+}
+
+impl PartialOrd for DirectoryChild {
+ fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
+ let entry_type_ord = self.entry_type.cmp(&other.entry_type);
+ let final_order = match entry_type_ord {
+ Ordering::Equal => self.byte_path.cmp(&other.byte_path),
+ _ => entry_type_ord,
+ };
+ Some(final_order)
+ }
+}
+
+impl Ord for DirectoryChild {
+ fn cmp(&self, other: &Self) -> Ordering {
+ let entry_type_ord = self.entry_type.cmp(&other.entry_type);
+ match entry_type_ord {
+ Ordering::Equal => self.byte_path.cmp(&other.byte_path),
+ _ => entry_type_ord,
+ }
+ }
+}