Trait casper_execution_engine::storage::store::Store
source · pub trait Store<K, V> {
type Error: From<Error>;
type Handle;
// Required method
fn handle(&self) -> Self::Handle;
// Provided methods
fn get<T>(&self, txn: &T, key: &K) -> Result<Option<V>, Self::Error>
where T: Readable<Handle = Self::Handle>,
K: AsRef<[u8]>,
V: FromBytes,
Self::Error: From<T::Error> { ... }
fn get_raw<T>(&self, txn: &T, key: &K) -> Result<Option<Bytes>, Self::Error>
where T: Readable<Handle = Self::Handle>,
K: AsRef<[u8]>,
Self::Error: From<T::Error> { ... }
fn put<T>(&self, txn: &mut T, key: &K, value: &V) -> Result<(), Self::Error>
where T: Writable<Handle = Self::Handle>,
K: AsRef<[u8]>,
V: ToBytes,
Self::Error: From<T::Error> { ... }
fn put_raw<T>(
&self,
txn: &mut T,
key: &K,
value_bytes: Cow<'_, [u8]>
) -> Result<(), Self::Error>
where T: Writable<Handle = Self::Handle>,
K: AsRef<[u8]>,
Self::Error: From<T::Error> { ... }
}
Expand description
Store is responsible for abstracting get
and put
operations over the underlying store
specified by its associated Handle
type.
Required Associated Types§
Required Methods§
Provided Methods§
sourcefn get<T>(&self, txn: &T, key: &K) -> Result<Option<V>, Self::Error>where
T: Readable<Handle = Self::Handle>,
K: AsRef<[u8]>,
V: FromBytes,
Self::Error: From<T::Error>,
fn get<T>(&self, txn: &T, key: &K) -> Result<Option<V>, Self::Error>where T: Readable<Handle = Self::Handle>, K: AsRef<[u8]>, V: FromBytes, Self::Error: From<T::Error>,
Returns an optional value (may exist or not) as read through a transaction, or an error
of the associated Self::Error
variety.
sourcefn get_raw<T>(&self, txn: &T, key: &K) -> Result<Option<Bytes>, Self::Error>where
T: Readable<Handle = Self::Handle>,
K: AsRef<[u8]>,
Self::Error: From<T::Error>,
fn get_raw<T>(&self, txn: &T, key: &K) -> Result<Option<Bytes>, Self::Error>where T: Readable<Handle = Self::Handle>, K: AsRef<[u8]>, Self::Error: From<T::Error>,
Returns an optional value (may exist or not) as read through a transaction, or an error
of the associated Self::Error
variety.
sourcefn put<T>(&self, txn: &mut T, key: &K, value: &V) -> Result<(), Self::Error>where
T: Writable<Handle = Self::Handle>,
K: AsRef<[u8]>,
V: ToBytes,
Self::Error: From<T::Error>,
fn put<T>(&self, txn: &mut T, key: &K, value: &V) -> Result<(), Self::Error>where T: Writable<Handle = Self::Handle>, K: AsRef<[u8]>, V: ToBytes, Self::Error: From<T::Error>,
Puts a value
into the store at key
within a transaction, potentially returning an
error of type Self::Error
if that fails.
sourcefn put_raw<T>(
&self,
txn: &mut T,
key: &K,
value_bytes: Cow<'_, [u8]>
) -> Result<(), Self::Error>where
T: Writable<Handle = Self::Handle>,
K: AsRef<[u8]>,
Self::Error: From<T::Error>,
fn put_raw<T>( &self, txn: &mut T, key: &K, value_bytes: Cow<'_, [u8]> ) -> Result<(), Self::Error>where T: Writable<Handle = Self::Handle>, K: AsRef<[u8]>, Self::Error: From<T::Error>,
Puts a raw value
into the store at key
within a transaction, potentially returning an
error of type Self::Error
if that fails.
This accepts a Cow
object as a value to allow different implementations to choose if
they want to use owned value (i.e. put it in a cache without cloning) or the raw bytes
(write it into a persistent store).