Trait DB

Source
pub trait DB:
    Send
    + Sync
    + 'static {
    type P<'a>: Persist;

    // Required methods
    fn create_or_open<T>(path: T, opts: DatabaseOptions) -> Self
       where T: AsRef<Path>;
    fn view<F, T>(&self, f: F) -> T
       where F: for<'a> FnOnce(&Self::P<'a>) -> T;
    fn update<F, T>(&self, f: F) -> Result<T>
       where F: for<'a> FnOnce(&mut Self::P<'a>) -> Result<T>;
    fn update_dry_run<F, T>(&self, dry_run: bool, f: F) -> Result<T>
       where F: for<'a> FnOnce(&mut Self::P<'a>) -> Result<T>;
    fn close(&mut self);
}

Required Associated Types§

Source

type P<'a>: Persist

Required Methods§

Source

fn create_or_open<T>(path: T, opts: DatabaseOptions) -> Self
where T: AsRef<Path>,

Creates or open a database located at this path.

Panics if opening db or creating one fails.

Source

fn view<F, T>(&self, f: F) -> T
where F: for<'a> FnOnce(&Self::P<'a>) -> T,

Provides a managed execution of a read-only isolated transaction.

Source

fn update<F, T>(&self, f: F) -> Result<T>
where F: for<'a> FnOnce(&mut Self::P<'a>) -> Result<T>,

Provides a managed execution of a read-write atomic transaction.

An atomic transaction is an indivisible and irreducible series of database operations such that either all occur, or nothing occurs.

Transaction commit will happen only if no error is returned by fn and no panic is raised on fn execution.

Source

fn update_dry_run<F, T>(&self, dry_run: bool, f: F) -> Result<T>
where F: for<'a> FnOnce(&mut Self::P<'a>) -> Result<T>,

Source

fn close(&mut self)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl DB for Backend

Source§

type P<'a> = DBTransaction<'a, DBCommon<SingleThreaded, OptimisticTransactionDBInner>>