1use crate::ffi;
2use crate::{handle::Handle, ColumnFamily, Error, FlushOptions};
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
14pub trait FlushCF {
15 fn flush_cf_opt(&self, cf: &ColumnFamily, flushopts: &FlushOptions) -> Result<(), Error>;
17
18 fn flush_cf(&self, cf: &ColumnFamily) -> Result<(), Error> {
21 self.flush_cf_opt(cf, &FlushOptions::default())
22 }
23}
24
25impl<T> Flush for T
26where
27 T: Handle<ffi::rocksdb_t> + super::Write,
28{
29 fn flush_opt(&self, flushopts: &FlushOptions) -> Result<(), Error> {
30 unsafe {
31 ffi_try!(ffi::rocksdb_flush(self.handle(), flushopts.inner,));
32 }
33 Ok(())
34 }
35}
36
37impl<T> FlushCF for T
38where
39 T: Handle<ffi::rocksdb_t> + super::Write,
40{
41 fn flush_cf_opt(&self, cf: &ColumnFamily, flushopts: &FlushOptions) -> Result<(), Error> {
42 unsafe {
43 ffi_try!(ffi::rocksdb_flush_cf(
44 self.handle(),
45 flushopts.inner,
46 cf.inner,
47 ));
48 }
49 Ok(())
50 }
51}