use crate::ffi;
use crate::{handle::Handle, ColumnFamily, Error, FlushOptions};
pub trait Flush {
fn flush_opt(&self, flushopts: &FlushOptions) -> Result<(), Error>;
fn flush(&self) -> Result<(), Error> {
self.flush_opt(&FlushOptions::default())
}
}
pub trait FlushCF {
fn flush_cf_opt(&self, cf: &ColumnFamily, flushopts: &FlushOptions) -> Result<(), Error>;
fn flush_cf(&self, cf: &ColumnFamily) -> Result<(), Error> {
self.flush_cf_opt(cf, &FlushOptions::default())
}
}
impl<T> Flush for T
where
T: Handle<ffi::rocksdb_t> + super::Write,
{
fn flush_opt(&self, flushopts: &FlushOptions) -> Result<(), Error> {
unsafe {
ffi_try!(ffi::rocksdb_flush(self.handle(), flushopts.inner,));
}
Ok(())
}
}
impl<T> FlushCF for T
where
T: Handle<ffi::rocksdb_t> + super::Write,
{
fn flush_cf_opt(&self, cf: &ColumnFamily, flushopts: &FlushOptions) -> Result<(), Error> {
unsafe {
ffi_try!(ffi::rocksdb_flush_cf(
self.handle(),
flushopts.inner,
cf.inner,
));
}
Ok(())
}
}