x 1 месяц назад
Родитель
Сommit
52ff2bf06e
1 измененных файлов с 15 добавлено и 0 удалено
  1. 15 0
      src/tree.rs

+ 15 - 0
src/tree.rs

@@ -50,6 +50,21 @@ impl Tree {
         &self.tree
         &self.tree
     }
     }
 
 
+    /// Returns the name of the tree.
+    pub fn name(&self) -> Result<String> {
+        #[cfg(feature = "sled-backend")]
+        {
+            match String::from_utf8(self.tree.name().to_vec()) {
+                Ok(s) => Ok(s),
+                Err(e) => Err(crate::Error::MalformedTreeMame(e.to_string())),
+            }
+        }
+        #[cfg(feature = "fjall-backend")]
+        {
+            Ok(self.tree.name().to_string())
+        }
+    }
+
     /// Returns true if the Tree contains a value for the specified key.
     /// Returns true if the Tree contains a value for the specified key.
     pub fn contains_key(&self, k: &[u8]) -> Result<bool> {
     pub fn contains_key(&self, k: &[u8]) -> Result<bool> {
         Ok(self.tree.contains_key(k)?)
         Ok(self.tree.contains_key(k)?)