Struct kaspa_database::prelude::CachedDbItem
source · pub struct CachedDbItem<T> { /* private fields */ }Expand description
A cached DB item with concurrency support
Implementations§
source§impl<T> CachedDbItem<T>
impl<T> CachedDbItem<T>
pub fn new(db: Arc<DB>, key: Vec<u8>) -> Self
pub fn read(&self) -> Result<T, StoreError>where T: Clone + DeserializeOwned,
pub fn write( &mut self, writer: impl DbWriter, item: &T ) -> Result<(), StoreError>where T: Clone + Serialize,
pub fn remove(&mut self, writer: impl DbWriter) -> Result<(), StoreError>
pub fn update<F>( &mut self, writer: impl DbWriter, op: F ) -> Result<T, StoreError>where T: Clone + Serialize + DeserializeOwned, F: Fn(T) -> T,
Trait Implementations§
source§impl<T: Clone> Clone for CachedDbItem<T>
impl<T: Clone> Clone for CachedDbItem<T>
source§fn clone(&self) -> CachedDbItem<T>
fn clone(&self) -> CachedDbItem<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more