Merge pull request #75 from kaedroho/db-path

Port path() method from ngauts fork and implement Debug for DB
master
Tyler Neely 8 years ago committed by GitHub
commit 803f2380c2
  1. 12
      src/rocksdb.rs

@ -32,6 +32,7 @@ use rocksdb_options::{Options, WriteOptions};
pub struct DB { pub struct DB {
inner: rocksdb_ffi::DBInstance, inner: rocksdb_ffi::DBInstance,
cfs: BTreeMap<String, DBCFHandle>, cfs: BTreeMap<String, DBCFHandle>,
path: String,
} }
unsafe impl Send for DB {} unsafe impl Send for DB {}
@ -405,6 +406,7 @@ impl DB {
Ok(DB { Ok(DB {
inner: db, inner: db,
cfs: cf_map, cfs: cf_map,
path: path.to_owned(),
}) })
} }
@ -442,6 +444,10 @@ impl DB {
Ok(()) Ok(())
} }
pub fn path(&self) -> &str {
&self.path
}
pub fn write_opt(&self, pub fn write_opt(&self,
batch: WriteBatch, batch: WriteBatch,
writeopts: &WriteOptions) 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 { impl Writable for WriteBatch {
/// Insert a value into the database under the given key /// Insert a value into the database under the given key
fn put(&self, key: &[u8], value: &[u8]) -> Result<(), Error> { fn put(&self, key: &[u8], value: &[u8]) -> Result<(), Error> {

Loading…
Cancel
Save