pub struct Database { /* private fields */ }

Implementations§

source§

impl Database

source

pub fn open<P: AsRef<Path>>(path: P, config: DatabaseConfig) -> Result<Self>

Initialization

source

pub fn open_with_columns<P: AsRef<Path>>(path: P, columns: u32) -> Result<Self>

source

pub fn open_in_memory_with_columns<P: AsRef<Path>>( path: P, columns: u32 ) -> Result<Self>

source

pub fn path(&self) -> PathBuf

source

pub fn config(&self) -> DatabaseConfig

source

pub fn num_columns(&self) -> Result<u32>

Low level operations

source

pub fn num_keys(&self, col: u32) -> Result<u64>

The number of keys in a column (estimated).

source

pub fn remove_last_column(&self) -> Result<()>

Remove the last column family in the database. The deletion is definitive.

source

pub fn add_column(&self) -> Result<()>

Add a new column family to the DB.

source

pub fn transaction(&self) -> DBTransaction

Helper to create new transaction for this database.

Trait Implementations§

source§

impl Clone for Database

source§

fn clone(&self) -> Database

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl KeyValueDB for Database

source§

fn delete<'a>( &self, col: u32, key: &'a [u8] ) -> Pin<Box<dyn Future<Output = Result<Option<DBValue>>> + Send + 'a>>

Remove a value by key, returning the old value

source§

fn get<'a>( &self, col: u32, key: &'a [u8] ) -> Pin<Box<dyn Future<Output = Result<Option<DBValue>>> + Send + 'a>>

Get a value by key.
source§

fn write( &self, transaction: DBTransaction ) -> Pin<Box<dyn Future<Output = Result<(), DBTransactionError>> + Send + 'static>>

Write a transaction of changes to the backing store.
source§

fn iter<'a, T: 'a, F: FnMut(DBKeyValueRef<'_>) -> Result<Option<T>> + Send + Sync + 'a>( &self, col: u32, prefix: Option<&'a [u8]>, f: F ) -> Pin<Box<dyn Future<Output = Result<Option<T>>> + Send + 'a>>

Iterate over the data for a given column. Return all key/value pairs, optionally where the key starts with the given prefix. Iterator closure returns true for more items, false to stop iteration.
source§

fn iter_keys<'a, T: 'a, F: FnMut(DBKeyRef<'_>) -> Result<Option<T>> + Send + Sync + 'a>( &self, col: u32, prefix: Option<&'a [u8]>, f: F ) -> Pin<Box<dyn Future<Output = Result<Option<T>>> + Send + 'a>>

Iterate over the data for a given column. Return all keys, optionally where the key starts with the given prefix. Iterator closure returns true for more items, false to stop iteration.
source§

fn io_stats(&self, kind: IoStatsKind) -> IoStats

Query statistics. Read more
source§

fn restore(&self, _new_db: &str) -> Result<()>

Attempt to replace this database with a new one located at the given path.
source§

fn transaction(&self) -> DBTransaction

Helper to create a new transaction.
source§

fn has_key<'a>( &self, col: u32, key: &'a [u8] ) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'a, Global>>

Check for the existence of a value by key.
source§

fn has_prefix<'a>( &self, col: u32, prefix: &'a [u8] ) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'a, Global>>

Check for the existence of a value by prefix.
source§

fn first_with_prefix<'a>( &self, col: u32, prefix: &'a [u8] ) -> Pin<Box<dyn Future<Output = Result<Option<(Vec<u8, Global>, Vec<u8, Global>)>, Error>> + Send + 'a, Global>>

Get the first value matching the given prefix.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.