Database

Struct Database 

Source
pub struct Database { /* private fields */ }

Implementations§

Source§

impl Database

Source

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

Source

pub fn path(&self) -> PathBuf

Source

pub fn config(&self) -> DatabaseConfig

Source

pub fn columns(&self) -> u32

Source

pub fn control_table(&self) -> Arc<DatabaseTable>

Source

pub fn column_table(&self, col: u32) -> Arc<DatabaseTable>

Source

pub fn conn_blocking<T, F>(&self, func: F) -> Result<T, Error>
where F: FnOnce(&Connection) -> Result<T, Error> + Send + 'static, T: Send + 'static,

Source

pub async fn conn<T, F>(&self, func: F) -> Result<T, Error>
where F: FnOnce(&Connection) -> Result<T, Error> + Send + 'static, T: Send + 'static,

Source

pub async fn conn_mut<T, F>(&self, func: F) -> Result<T, Error>
where F: FnOnce(&mut Connection) -> Result<T, Error> + Send + 'static, T: Send + 'static,

Source

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

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

Source

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

Add a new column family to the DB.

Source

pub fn transaction(&self) -> DBTransaction

Helper to create new transaction for this database.

Source

pub async fn vacuum(&self) -> Result<(), Error>

Vacuum database

Trait Implementations§

Source§

impl Clone for Database

Source§

fn clone(&self) -> Database

Returns a duplicate 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( &self, col: u32, key: &[u8], ) -> Pin<Box<dyn Future<Output = Result<Option<DBValue>>> + Send + '_>>

Remove a value by key, returning the old value

Source§

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

Check for the existence of a value by key.

Source§

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

Check for the existence of a value by prefix.

Source§

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

Get the first value matching the given prefix.

Source§

fn cleanup(&self) -> Pin<Box<dyn Future<Output = Result<()>> + Send + '_>>

Vacuum database

Source§

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

Get a value by key.
Source§

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

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

fn iter<'a, T: Send + 'static, C: Send + 'static, F: FnMut(&mut C, DBKeyValueRef<'_>) -> Result<Option<T>> + Send + Sync + 'static>( &'a self, col: u32, prefix: Option<&'a [u8]>, context: C, f: F, ) -> Pin<Box<dyn Future<Output = Result<(C, 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: Send + 'static, C: Send + 'static, F: FnMut(&mut C, DBKeyRef<'_>) -> Result<Option<T>> + Send + Sync + 'static>( &'a self, col: u32, prefix: Option<&'a [u8]>, context: C, f: F, ) -> Pin<Box<dyn Future<Output = Result<(C, 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 num_columns(&self) -> Result<u32>

The number of column families in the db.
Source§

fn num_keys( &self, col: u32, ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + '_>>

The number of keys in a column (estimated).
Source§

fn transaction(&self) -> DBTransaction

Helper to create a new transaction.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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 T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.