1use super::Error;
2use rocksdb::DB;
3
4pub trait Mode {
5 fn is_read_only() -> bool;
6}
7
8pub struct ReadOnly;
9pub struct Writeable;
10
11impl Mode for ReadOnly {
12 fn is_read_only() -> bool {
13 true
14 }
15}
16impl Mode for Writeable {
17 fn is_read_only() -> bool {
18 false
19 }
20}
21
22pub trait Table: Sized {
23 type Counts;
24
25 fn underlying(&self) -> &DB;
26 fn get_counts(&self) -> Result<Self::Counts, Error>;
27
28 fn get_estimated_key_count(&self) -> Result<Option<u64>, Error> {
29 Ok(self
30 .underlying()
31 .property_int_value("rocksdb.estimate-num-keys")?)
32 }
33}