summary refs log tree commit diff
path: root/ripple/fossil/src/bin
diff options
context:
space:
mode:
Diffstat (limited to 'ripple/fossil/src/bin')
-rw-r--r--ripple/fossil/src/bin/mount.rs38
1 files changed, 26 insertions, 12 deletions
diff --git a/ripple/fossil/src/bin/mount.rs b/ripple/fossil/src/bin/mount.rs
index 0f9e2ec..c43a5ae 100644
--- a/ripple/fossil/src/bin/mount.rs
+++ b/ripple/fossil/src/bin/mount.rs
@@ -156,9 +156,9 @@ impl fuser::Filesystem for Filesystem {
 		let entry = name.to_str().and_then(|name| dir.lookup(name));
 		match entry {
 			None => reply.error(ENOENT),
-			Some((idx, node)) => {
-				let ino = parent + idx as u64 + 1;
-				reply.entry(&Duration::ZERO, &file_attr(ino, node), 0);
+			Some(entry) => {
+				let ino = parent + entry.index as u64 + 1;
+				reply.entry(&Duration::ZERO, &file_attr(ino, entry.node), 0);
 			}
 		}
 	}
@@ -328,13 +328,13 @@ impl fuser::Filesystem for Filesystem {
 			(ino, fuser::FileType::Directory, ".."),
 		];
 
-		for (name, idx, node) in dir.iter() {
-			let kind = match node {
+		for entry in dir.iter() {
+			let kind = match entry.node {
 				memtree::Node::Directory(_) => fuser::FileType::Directory,
 				memtree::Node::File(_) => fuser::FileType::RegularFile,
 				memtree::Node::Link { .. } => fuser::FileType::Symlink,
 			};
-			children.push((ino + idx as u64 + 1, kind, name));
+			children.push((ino + entry.index as u64 + 1, kind, entry.name));
 		}
 
 		for (offset, &(ino, kind, name)) in children.iter().enumerate().skip(offset as usize) {
@@ -684,20 +684,34 @@ mod memtree {
 		size: u32,
 	}
 
+	pub struct DirectoryEntry<'a> {
+		pub name: &'a str,
+		pub index: u32,
+		pub node: &'a Node,
+	}
+
 	impl Directory {
-		pub fn iter(&self) -> impl Iterator<Item = (&str, u32, &Node)> {
+		pub fn iter(&self) -> impl Iterator<Item = DirectoryEntry> {
 			let by_name = self.by_name.iter();
 			let by_index = self.by_index.iter();
 
 			by_name.zip(by_index).map(|((name, &idx), (&idy, node))| {
 				assert_eq!(idx, idy);
-				(name.as_str(), idx, node)
+				DirectoryEntry {
+					name: &name,
+					index: idx,
+					node,
+				}
 			})
 		}
 
-		pub fn lookup(&self, name: &str) -> Option<(u32, &Node)> {
-			let &idx = self.by_name.get(name)?;
-			Some((idx, &self.by_index[&idx]))
+		pub fn lookup<'a>(&self, name: &'a str) -> Option<DirectoryEntry> {
+			let (name, &index) = self.by_name.get_key_value(name)?;
+			Some(DirectoryEntry {
+				name,
+				index,
+				node: &self.by_index[&index],
+			})
 		}
 	}
 
@@ -715,7 +729,7 @@ mod memtree {
 	impl fmt::Debug for DirectoryMembers<'_> {
 		fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 			f.debug_map()
-				.entries(self.0.iter().map(|(name, idx, node)| ((name, idx), node)))
+				.entries(self.0.iter().map(|e| ((e.name, e.index), e.node)))
 				.finish()
 		}
 	}