pub struct Database { /* private fields */ }Implementations§
Source§impl Database
impl Database
pub fn open<P: AsRef<Path>>(path: P, config: DatabaseConfig) -> Result<Self>
pub fn path(&self) -> PathBuf
pub fn config(&self) -> DatabaseConfig
pub fn columns(&self) -> u32
pub fn control_table(&self) -> Arc<DatabaseTable>
pub fn column_table(&self, col: u32) -> Arc<DatabaseTable>
pub fn conn_blocking<T, F>(&self, func: F) -> Result<T, Error>
pub async fn conn<T, F>(&self, func: F) -> Result<T, Error>
pub async fn conn_mut<T, F>(&self, func: F) -> Result<T, Error>
Sourcepub fn remove_last_column(&self) -> Result<(), Error>
pub fn remove_last_column(&self) -> Result<(), Error>
Remove the last column family in the database. The deletion is definitive.
Sourcepub fn add_column(&self) -> Result<(), Error>
pub fn add_column(&self) -> Result<(), Error>
Add a new column family to the DB.
Sourcepub fn transaction(&self) -> DBTransaction
pub fn transaction(&self) -> DBTransaction
Helper to create new transaction for this database.
Trait Implementations§
Source§impl KeyValueDB for Database
impl KeyValueDB for Database
Source§fn delete(
&self,
col: u32,
key: &[u8],
) -> Pin<Box<dyn Future<Output = Result<Option<DBValue>>> + Send + '_>>
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>>
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>>
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>>
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 get(
&self,
col: u32,
key: &[u8],
) -> Pin<Box<dyn Future<Output = Result<Option<DBValue>>> + Send + '_>>
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 + '_>>
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>>
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>>
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 num_columns(&self) -> Result<u32>
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 + '_>>
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
fn transaction(&self) -> DBTransaction
Helper to create a new transaction.
Auto Trait Implementations§
impl Freeze for Database
impl !RefUnwindSafe for Database
impl Send for Database
impl Sync for Database
impl Unpin for Database
impl !UnwindSafe for Database
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more