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§
Required Methods§
Sourcefn create_or_open<T>(path: T, opts: DatabaseOptions) -> Self
fn create_or_open<T>(path: T, opts: DatabaseOptions) -> Self
Creates or open a database located at this path.
Panics if opening db or creating one fails.
Sourcefn view<F, T>(&self, f: F) -> T
fn view<F, T>(&self, f: F) -> T
Provides a managed execution of a read-only isolated transaction.
Sourcefn update<F, T>(&self, f: F) -> Result<T>
fn update<F, T>(&self, f: F) -> 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.
fn update_dry_run<F, T>(&self, dry_run: bool, f: F) -> Result<T>
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.