lighthouse-pulse/lighthouse/db/mod.rs
2018-09-18 15:59:44 +10:00

30 lines
527 B
Rust

extern crate rocksdb;
mod disk_db;
pub use self::disk_db::DiskDB;
type DBValue = Vec<u8>;
#[derive(Debug)]
pub struct DBError {
message: String
}
impl DBError {
pub fn new(message: String) -> Self {
Self { message }
}
}
pub trait ClientDB: Sync + Send {
fn create_col(&mut self, col: &str)
-> Result<(), DBError>;
fn get(&self, col: &str, key: &[u8])
-> Result<Option<DBValue>, DBError>;
fn put(&self, col: &str, key: &[u8], val: &[u8])
-> Result<(), DBError>;
}