aboutsummaryrefslogtreecommitdiff
path: root/src/db
diff options
context:
space:
mode:
Diffstat (limited to 'src/db')
-rw-r--r--src/db/lib.rs5
-rw-r--r--src/db/lmdb_adapter.rs4
-rw-r--r--src/db/sled_adapter.rs4
-rw-r--r--src/db/sqlite_adapter.rs4
4 files changed, 17 insertions, 0 deletions
diff --git a/src/db/lib.rs b/src/db/lib.rs
index 9fae7cc9..e9d3ea18 100644
--- a/src/db/lib.rs
+++ b/src/db/lib.rs
@@ -63,6 +63,10 @@ pub fn unabort<R, E>(res: TxResult<R, E>) -> TxOpResult<std::result::Result<R, E
// ----
impl Db {
+ pub fn engine(&self) -> String {
+ self.0.engine()
+ }
+
pub fn open_tree<S: AsRef<str>>(&self, name: S) -> Result<Tree> {
let tree_id = self.0.open_tree(name.as_ref())?;
Ok(Tree(self.0.clone(), tree_id))
@@ -298,6 +302,7 @@ impl<'a> Transaction<'a> {
// ---- Internal interfaces
pub(crate) trait IDb: Send + Sync {
+ fn engine(&self) -> String;
fn open_tree(&self, name: &str) -> Result<usize>;
fn list_trees(&self) -> Result<Vec<String>>;
diff --git a/src/db/lmdb_adapter.rs b/src/db/lmdb_adapter.rs
index 23b8c87e..74622919 100644
--- a/src/db/lmdb_adapter.rs
+++ b/src/db/lmdb_adapter.rs
@@ -57,6 +57,10 @@ impl LmdbDb {
}
impl IDb for LmdbDb {
+ fn engine(&self) -> String {
+ "LMDB (using Heed crate)".into()
+ }
+
fn open_tree(&self, name: &str) -> Result<usize> {
let mut trees = self.trees.write().unwrap();
if let Some(i) = trees.1.get(name) {
diff --git a/src/db/sled_adapter.rs b/src/db/sled_adapter.rs
index fb9353f0..982f8d82 100644
--- a/src/db/sled_adapter.rs
+++ b/src/db/sled_adapter.rs
@@ -58,6 +58,10 @@ impl SledDb {
}
impl IDb for SledDb {
+ fn engine(&self) -> String {
+ "Sled".into()
+ }
+
fn open_tree(&self, name: &str) -> Result<usize> {
let mut trees = self.trees.write().unwrap();
if let Some(i) = trees.1.get(name) {
diff --git a/src/db/sqlite_adapter.rs b/src/db/sqlite_adapter.rs
index 251dcafb..84883772 100644
--- a/src/db/sqlite_adapter.rs
+++ b/src/db/sqlite_adapter.rs
@@ -71,6 +71,10 @@ impl SqliteDbInner {
}
impl IDb for SqliteDb {
+ fn engine(&self) -> String {
+ "Sqlite3 (using rusqlite crate)".into()
+ }
+
fn open_tree(&self, name: &str) -> Result<usize> {
let name = format!("tree_{}", name.replace(':', "_COLON_"));
let mut this = self.0.lock().unwrap();