diff --git a/src/rocksdb.rs b/src/rocksdb.rs index 3a49a7d..eeb22f2 100644 --- a/src/rocksdb.rs +++ b/src/rocksdb.rs @@ -32,6 +32,7 @@ use rocksdb_options::{Options, WriteOptions}; pub struct DB { inner: rocksdb_ffi::DBInstance, cfs: BTreeMap, + path: String, } unsafe impl Send for DB {} @@ -405,6 +406,7 @@ impl DB { Ok(DB { inner: db, cfs: cf_map, + path: path.to_owned(), }) } @@ -442,6 +444,10 @@ impl DB { Ok(()) } + pub fn path(&self) -> &str { + &self.path + } + pub fn write_opt(&self, batch: WriteBatch, writeopts: &WriteOptions) @@ -814,6 +820,12 @@ impl Drop for DB { } } +impl fmt::Debug for DB { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "RocksDB {{ path: {:?} }}", self.path()) + } +} + impl Writable for WriteBatch { /// Insert a value into the database under the given key fn put(&self, key: &[u8], value: &[u8]) -> Result<(), Error> {