Add property_value functions

master
Martin Ek 5 years ago
parent 9e15b513bc
commit 22b34a40cb
  1. 21
      src/db.rs

@ -1152,6 +1152,27 @@ impl DB {
))
})
}
pub fn property_value(&self, name: &str) -> Option<String> {
let prop_name = CString::new(name).unwrap();
unsafe {
let value = ffi::rocksdb_property_value(self.inner, prop_name.as_ptr());
if value.is_null() {
return None;
}
let s = CStr::from_ptr(value).to_str().unwrap().to_owned();
libc::free(value as *mut c_void);
Some(s)
}
}
pub fn property_int_value(&self, name: &str) -> Option<u64> {
match self.property_value(name) {
Some(value) => value.parse::<u64>().ok(),
None => None,
}
}
}
impl WriteBatch {

Loading…
Cancel
Save