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 open_with_columns<P: AsRef<Path>>(path: P, columns: u32) -> Result<Self>
pub fn open_in_memory_with_columns<P: AsRef<Path>>( path: P, columns: u32, ) -> Result<Self>
pub fn path(&self) -> PathBuf
pub fn config(&self) -> DatabaseConfig
Sourcepub fn remove_last_column(&self) -> Result<()>
pub fn remove_last_column(&self) -> Result<()>
Remove the last column family in the database. The deletion is definitive.
Sourcepub fn add_column(&self) -> Result<()>
pub fn add_column(&self) -> Result<()>
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<'a>(
&self,
col: u32,
key: &'a [u8],
) -> Pin<Box<dyn Future<Output = Result<Option<DBValue>>> + Send + 'a>>
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>>
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>>
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>>
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>>
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 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 restore(&self, _new_db: &str) -> Result<()>
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
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>>
fn has_key<'a>( &self, col: u32, key: &'a [u8], ) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'a>>
Check for the existence of a value by key.
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