|
|
|
@ -659,6 +659,32 @@ impl DB { |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub fn list_cf<P: AsRef<Path>>(opts: &Options, path: P) -> Result<Vec<String>, Error> { |
|
|
|
|
let path = path.as_ref(); |
|
|
|
|
let cpath = match CString::new(path.to_string_lossy().as_bytes()) { |
|
|
|
|
Ok(c) => c, |
|
|
|
|
Err(_) => { |
|
|
|
|
return Err(Error::new("Failed to convert path to CString \ |
|
|
|
|
when opening DB." |
|
|
|
|
.to_owned())) |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
let mut length = 0; |
|
|
|
|
|
|
|
|
|
unsafe { |
|
|
|
|
let ptr = ffi_try!(ffi::rocksdb_list_column_families(opts.inner, |
|
|
|
|
cpath.as_ptr() as *const _, |
|
|
|
|
&mut length)); |
|
|
|
|
|
|
|
|
|
let vec = Vec::from_raw_parts(ptr, length, length).iter().map(|&ptr| { |
|
|
|
|
CString::from_raw(ptr).into_string().unwrap() |
|
|
|
|
}).collect(); |
|
|
|
|
Ok(vec) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn destroy<P: AsRef<Path>>(opts: &Options, path: P) -> Result<(), Error> { |
|
|
|
|
let cpath = CString::new(path.as_ref().to_string_lossy().as_bytes()).unwrap(); |
|
|
|
|
unsafe { |
|
|
|
|