Implement get and put on ClientDB trait
This commit is contained in:
parent
33b1e6ddf4
commit
3876c0261a
@ -4,18 +4,23 @@ mod disk_db;
|
|||||||
|
|
||||||
pub use self::disk_db::DiskDB;
|
pub use self::disk_db::DiskDB;
|
||||||
|
|
||||||
|
type DBValue = Vec<u8>;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct DBError {
|
pub struct DBError {
|
||||||
message: String
|
message: String
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DBError {
|
impl DBError {
|
||||||
fn new(message: String) -> Self {
|
pub fn new(message: String) -> Self {
|
||||||
Self { message }
|
Self { message }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ClientDB: Sync + Send {
|
pub trait ClientDB: Sync + Send {
|
||||||
fn get(&self, col: &str, key: &[u8])
|
fn get(&self, col: &str, key: &[u8])
|
||||||
-> Result<Option<&[u8]>, DBError>;
|
-> Result<Option<DBValue>, DBError>;
|
||||||
|
|
||||||
|
fn put(&self, col: &str, key: &[u8], val: &[u8])
|
||||||
|
-> Result<(), DBError>;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user