ethcore-db crate (#1097)
* trait * implentated, lifetime issue still * full api * test mod * working open * get/retrieve * fix warnings and bug * working serialization of &[u8] parameters * client attributes * fix empty payload ser/de * [ci skip] debug assert out * extra deserialization test * extra serialization test * extra serialization test * serialization fixes, nupdate rocksdb * open test working * result bug & remove some scaffolds * fix warnings * more simple tests * consistent quotes * get rid of dedicated is_open flag * hashmap -> btreemap
This commit is contained in:
@@ -42,3 +42,17 @@ pub enum EnumWithStruct {
|
||||
Left,
|
||||
Right { how_much: u64 },
|
||||
}
|
||||
|
||||
#[derive(Binary)]
|
||||
pub struct TwoVec {
|
||||
v1: Vec<u8>,
|
||||
v2: Vec<u8>,
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn opt_two_vec() {
|
||||
let example: Option<TwoVec> = None;
|
||||
|
||||
let serialized = ::ipc::binary::serialize(&example).unwrap();
|
||||
assert_eq!(serialized, vec![0u8; 16]);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ pub struct DB<L: Sized> {
|
||||
|
||||
pub trait DBWriter {
|
||||
fn write(&self, data: Vec<u8>) -> Result<(), DBError>;
|
||||
fn write_slice(&self, data: &[u8]) -> Result<(), DBError>;
|
||||
}
|
||||
|
||||
impl<L: Sized> IpcConfig for DB<L> {}
|
||||
@@ -44,5 +45,11 @@ impl<L: Sized> DBWriter for DB<L> {
|
||||
*writes = *writes + data.len() as u64;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn write_slice(&self, data: &[u8]) -> Result<(), DBError> {
|
||||
let mut writes = self.writes.write().unwrap();
|
||||
*writes = *writes + data.len() as u64;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user