Skip to main content

TryCachingDb

Trait TryCachingDb 

Source
pub trait TryCachingDb {
    type Error: Error;

    // Required methods
    fn cache(&self) -> &Cache;
    fn try_cache_mut(&mut self) -> Result<&mut Cache, Self::Error>;
    fn try_into_cache(self) -> Result<Cache, Self::Error>;

    // Provided methods
    fn try_extend_ref(&mut self, cache: &Cache) -> Result<(), Self::Error>
       where Self: Sized { ... }
    fn try_extend(&mut self, cache: Cache) -> Result<(), Self::Error>
       where Self: Sized { ... }
}
Expand description

Trait for Databases that have a Cache and can fail to mutably access it. E.g. Arc<CacheDB<Db>>

Required Associated Types§

Source

type Error: Error

Error type to be thrown when cache access fails.

Required Methods§

Source

fn cache(&self) -> &Cache

Attempt to get the cache.

Source

fn try_cache_mut(&mut self) -> Result<&mut Cache, Self::Error>

Attempt to get the cache mutably.

Source

fn try_into_cache(self) -> Result<Cache, Self::Error>

Attempt to deconstruct into the cache

Provided Methods§

Source

fn try_extend_ref(&mut self, cache: &Cache) -> Result<(), Self::Error>
where Self: Sized,

Attempt to fold a cache into the database.

The behavior is as follows:

  • Accounts are overridden with outer accounts
  • Contracts are overridden with outer contracts
  • Logs are appended
  • Block hashes are overridden with outer block hashes
Source

fn try_extend(&mut self, cache: Cache) -> Result<(), Self::Error>
where Self: Sized,

Attempt to extend the cache with the given cache by moving data.

The behavior is as follows:

  • Accounts are overridden with outer accounts
  • Contracts are overridden with outer contracts
  • Logs are appended
  • Block hashes are overridden with outer block hashes

Implementations on Foreign Types§

Source§

impl<Db> TryCachingDb for Arc<Db>
where Db: CachingDb,

Implementors§