removed tree::find_key/find_key_rev in favour of entry/_rev

This commit is contained in:
Janis 2023-04-05 21:31:56 +02:00
parent db762e0187
commit 6762812ec5
2 changed files with 5 additions and 24 deletions

View file

@ -339,26 +339,6 @@ impl<R: super::Read> Tree<R> {
Ok(entry) Ok(entry)
} }
pub fn find_key<K>(&self, key: &K) -> Result<Option<(Item, TreeItem)>>
where
K: PartialEq<Key> + PartialOrd<Key>,
{
match self.find_node(key)? {
Some(node) => node.parse_item().map(|item| Some(item)),
None => Ok(None),
}
}
pub fn find_key_rev<K>(&self, key: &K) -> Result<Option<(Item, TreeItem)>>
where
K: PartialEq<Key> + PartialOrd<Key>,
{
match self.find_node_rev(key)? {
Some(node) => node.parse_item().map(|item| Some(item)),
None => Ok(None),
}
}
pub fn find_range<K>(&self, key: &K) -> Result<Range<R>> pub fn find_range<K>(&self, key: &K) -> Result<Range<R>>
where where
K: PartialEq<Key> + PartialOrd<Key>, K: PartialEq<Key> + PartialOrd<Key>,

View file

@ -322,14 +322,15 @@ impl<R: super::Read> Volume2<R> {
0x8dbfc2d2, // crc of "default" 0x8dbfc2d2, // crc of "default"
); );
let subvol_root = root_tree let subvol_root = match root_tree.entry(&key)? {
.find_key(&key)? super::tree::entry::Entry::Occupied(entry) => Some(entry.value()?),
.ok_or(Error::NoDefaultSubvolRoot)?; super::tree::entry::Entry::Vacant(_) => None,
}
.ok_or(Error::NoDefaultSubvolRoot)?;
// if we found the dir entry of the "default subvol" (mharmstone nomenclature) // if we found the dir entry of the "default subvol" (mharmstone nomenclature)
// we then look for the root fs tree in the root tree with the ID found in the `.location` of the dir_item only (from mharmstone) // we then look for the root fs tree in the root tree with the ID found in the `.location` of the dir_item only (from mharmstone)
let subvol_id = subvol_root let subvol_id = subvol_root
.1
.as_dir_item() .as_dir_item()
.expect("dir item") .expect("dir item")
.first() .first()