1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use super::Error;
use rocksdb::DB;

pub trait Mode {
    fn is_read_only() -> bool;
}

pub struct ReadOnly;
pub struct Writeable;

impl Mode for ReadOnly {
    fn is_read_only() -> bool {
        true
    }
}
impl Mode for Writeable {
    fn is_read_only() -> bool {
        false
    }
}

pub trait Table: Sized {
    type Counts;

    fn underlying(&self) -> &DB;
    fn get_counts(&self) -> Result<Self::Counts, Error>;

    fn get_estimated_key_count(&self) -> Result<Option<u64>, Error> {
        Ok(self
            .underlying()
            .property_int_value("rocksdb.estimate-num-keys")?)
    }
}