use casper_types::bytesrepr::Bytes;
pub mod in_memory;
pub mod lmdb;
pub trait Transaction: Sized {
type Error;
type Handle;
fn commit(self) -> Result<(), Self::Error>;
fn abort(self) {
unimplemented!("Abort operations should be performed in Drop implementations.")
}
}
pub trait Readable: Transaction {
fn read(&self, handle: Self::Handle, key: &[u8]) -> Result<Option<Bytes>, Self::Error>;
}
pub trait Writable: Transaction {
fn write(&mut self, handle: Self::Handle, key: &[u8], value: &[u8]) -> Result<(), Self::Error>;
}
pub trait TransactionSource<'a> {
type Error;
type Handle;
type ReadTransaction: Readable<Error = Self::Error, Handle = Self::Handle>;
type ReadWriteTransaction: Readable<Error = Self::Error, Handle = Self::Handle>
+ Writable<Error = Self::Error, Handle = Self::Handle>;
fn create_read_txn(&'a self) -> Result<Self::ReadTransaction, Self::Error>;
fn create_read_write_txn(&'a self) -> Result<Self::ReadWriteTransaction, Self::Error>;
}