1use crate::ffi;
2use crate::{ColumnFamily, Error, FlushOptions, handle::Handle};
3
4pub trait Flush {
5 fn flush_opt(&self, flushopts: &FlushOptions) -> Result<(), Error>;
7
8 fn flush(&self) -> Result<(), Error> {
10 self.flush_opt(&FlushOptions::default())
11 }
12}
13
14#[allow(dead_code)]
15pub trait FlushCF {
16 fn flush_cf_opt(&self, cf: &ColumnFamily, flushopts: &FlushOptions) -> Result<(), Error>;
18
19 fn flush_cf(&self, cf: &ColumnFamily) -> Result<(), Error> {
22 self.flush_cf_opt(cf, &FlushOptions::default())
23 }
24}
25
26impl<T> Flush for T
27where
28 T: Handle<ffi::rocksdb_t> + super::Write,
29{
30 fn flush_opt(&self, flushopts: &FlushOptions) -> Result<(), Error> {
31 unsafe {
32 ffi_try!(ffi::rocksdb_flush(self.handle(), flushopts.inner,));
33 }
34 Ok(())
35 }
36}
37
38impl<T> FlushCF for T
39where
40 T: Handle<ffi::rocksdb_t> + super::Write,
41{
42 fn flush_cf_opt(&self, cf: &ColumnFamily, flushopts: &FlushOptions) -> Result<(), Error> {
43 unsafe {
44 ffi_try!(ffi::rocksdb_flush_cf(
45 self.handle(),
46 flushopts.inner,
47 cf.inner,
48 ));
49 }
50 Ok(())
51 }
52}