Trait mmtkvdb::EnvRef

source ·
pub trait EnvRef {
    // Required method
    unsafe fn open_or_create_db<K, V, C>(
        &mut self,
        options: &DbSpec<K, V, C>
    ) -> Result<Db<K, V, C>>
       where K: Storable + ?Sized,
             V: Storable + ?Sized,
             C: Constraint;
}
Expand description

Abstraction over &EnvRo and &mut EnvRw, which allows creating databases in the latter case if non-existing

This trait is only needed if you want to create generic code which works on either &EnvRo or &mut EnvRw and creates databases in the latter case if non-existing. In most cases, EnvRo or EnvRw can be used directly. (Note that you can call EnvRo’s methods on EnvRw automatically due to Deref coercion.)

Required Methods§

source

unsafe fn open_or_create_db<K, V, C>( &mut self, options: &DbSpec<K, V, C> ) -> Result<Db<K, V, C>>where K: Storable + ?Sized, V: Storable + ?Sized, C: Constraint,

Open database in environment and, if possible, create if non-existing

Note that the implementation of EnvRef for &EnvRo does not create any database if non-existing.

Safety
  • If a database exists already, it must have been created with compatible options.
  • Implementation of Storable for the used keys and values must behave the same as when the database was created.

Implementations on Foreign Types§

source§

impl<T: Env> EnvRef for &T

source§

unsafe fn open_or_create_db<K, V, C>( &mut self, options: &DbSpec<K, V, C> ) -> Result<Db<K, V, C>>where K: Storable + ?Sized, V: Storable + ?Sized, C: Constraint,

Implementors§

source§

impl EnvRef for &mut EnvRw