From 315fc1fbe3c5de7f01d5395a21639e3e498bf0ba Mon Sep 17 00:00:00 2001 From: Quentin de Quelen Date: Fri, 22 Feb 2019 13:49:04 +0100 Subject: [PATCH] feat: Add accessor for database and index path --- src/database/mod.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/database/mod.rs b/src/database/mod.rs index 7a2982fb5..a4c5d4956 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -293,6 +293,10 @@ impl DatabaseIndex { Ok(view) } + + fn path(&self) -> &Path { + self.path.as_path() + } } impl Drop for DatabaseIndex { @@ -409,6 +413,16 @@ impl Database { Ok(index_guard.val().update_config(config)?) } + pub fn path(&self) -> &Path { + self.path.as_path() + } + + pub fn index_path(&self, index: &str) -> Result> { + let index_guard = self.indexes.get(index).ok_or("Index not found")?; + let path = index_guard.val().path(); + Ok(path.to_path_buf()) + } + } #[cfg(test)]