diff --git a/atrium-repo/src/mst.rs b/atrium-repo/src/mst.rs index 50f6d1ea..9476436c 100644 --- a/atrium-repo/src/mst.rs +++ b/atrium-repo/src/mst.rs @@ -651,8 +651,8 @@ impl Tree { } } - /// Returns a stream of all keys in this tree, in lexicographic order. - pub fn keys<'a>(&'a mut self) -> impl Stream> + 'a { + /// Returns a stream of all entries in this tree, in lexicographic order. + pub fn entries<'a>(&'a mut self) -> impl Stream> + 'a { // Start from the root of the tree. let mut stack = vec![Located::InSubtree(self.root)]; @@ -667,17 +667,22 @@ impl Tree { stack.push(Located::InSubtree(entry.clone())); } NodeEntry::Leaf(entry) => { - stack.push(Located::Entry(entry.key.clone())); + stack.push(Located::Entry((entry.key.clone(), entry.value.clone()))); } } } } - Located::Entry(key) => yield key, + Located::Entry((key, value)) => yield (key, value), } } } } + /// Returns a stream of all keys in this tree, in lexicographic order. + pub fn keys<'a>(&'a mut self) -> impl Stream> + 'a { + self.entries().map(|e| e).map(|e| e.map(|(k, _)| k)) + } + /// Returns the specified record from the repository, or `None` if it does not exist. pub async fn get(&mut self, key: &str) -> Result, Error> { match algos::traverse(&mut self.storage, self.root, algos::traverse_find(key)).await {