2018-08-16 04:17:28 +00:00
|
|
|
extern crate rocksdb;
|
|
|
|
|
2018-09-17 07:52:32 +00:00
|
|
|
mod disk_db;
|
|
|
|
|
|
|
|
pub use self::disk_db::DiskDB;
|
|
|
|
|
2018-09-18 00:27:29 +00:00
|
|
|
type DBValue = Vec<u8>;
|
|
|
|
|
2018-09-17 07:52:32 +00:00
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct DBError {
|
|
|
|
message: String
|
|
|
|
}
|
|
|
|
|
|
|
|
impl DBError {
|
2018-09-18 00:27:29 +00:00
|
|
|
pub fn new(message: String) -> Self {
|
2018-09-17 07:52:32 +00:00
|
|
|
Self { message }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait ClientDB: Sync + Send {
|
2018-09-18 05:59:44 +00:00
|
|
|
fn create_col(&mut self, col: &str)
|
|
|
|
-> Result<(), DBError>;
|
|
|
|
|
2018-09-17 07:52:32 +00:00
|
|
|
fn get(&self, col: &str, key: &[u8])
|
2018-09-18 00:27:29 +00:00
|
|
|
-> Result<Option<DBValue>, DBError>;
|
|
|
|
|
|
|
|
fn put(&self, col: &str, key: &[u8], val: &[u8])
|
|
|
|
-> Result<(), DBError>;
|
2018-08-16 04:17:28 +00:00
|
|
|
}
|