Struct kvdb_rocksdb::Database
source · [−]pub struct Database { /* private fields */ }
Expand description
Key-Value database.
Implementations
sourceimpl Database
impl Database
sourcepub fn open_default(path: &str) -> Result<Database>
pub fn open_default(path: &str) -> Result<Database>
Open database with default settings.
sourcepub fn open(config: &DatabaseConfig, path: &str) -> Result<Database>
pub fn open(config: &DatabaseConfig, path: &str) -> Result<Database>
Open database file. Creates if it does not exist.
sourcepub fn transaction(&self) -> DBTransaction
pub fn transaction(&self) -> DBTransaction
Helper to create new transaction for this database.
sourcepub fn write_buffered(&self, tr: DBTransaction)
pub fn write_buffered(&self, tr: DBTransaction)
Commit transaction to database.
sourcepub fn write(&self, tr: DBTransaction) -> Result<()>
pub fn write(&self, tr: DBTransaction) -> Result<()>
Commit transaction to database.
sourcepub fn get_by_prefix(
&self,
col: Option<u32>,
prefix: &[u8]
) -> Option<Box<[u8]>>
pub fn get_by_prefix(
&self,
col: Option<u32>,
prefix: &[u8]
) -> Option<Box<[u8]>>
Get value by partial key. Prefix size should match configured prefix size. Only searches flushed values.
sourcepub fn iter(&self, col: Option<u32>) -> Option<DatabaseIterator<'_>>
pub fn iter(&self, col: Option<u32>) -> Option<DatabaseIterator<'_>>
Get database iterator for flushed data.
sourcepub fn restore(&self, new_db: &str) -> Result<()>
pub fn restore(&self, new_db: &str) -> Result<()>
Restore the database from a copy at given path.
sourcepub fn num_columns(&self) -> u32
pub fn num_columns(&self) -> u32
The number of non-default column families.
sourcepub fn drop_column(&self) -> Result<()>
pub fn drop_column(&self) -> Result<()>
Drop a column family.
sourcepub fn add_column(&self) -> Result<()>
pub fn add_column(&self) -> Result<()>
Add a column family.
Trait Implementations
sourceimpl KeyValueDB for Database
impl KeyValueDB for Database
sourcefn get_by_prefix(&self, col: Option<u32>, prefix: &[u8]) -> Option<Box<[u8]>>
fn get_by_prefix(&self, col: Option<u32>, prefix: &[u8]) -> Option<Box<[u8]>>
Get a value by partial key. Only works for flushed data.
sourcefn write_buffered(&self, transaction: DBTransaction)
fn write_buffered(&self, transaction: DBTransaction)
Write a transaction of changes to the buffer.
sourcefn write(&self, transaction: DBTransaction) -> Result<()>
fn write(&self, transaction: DBTransaction) -> Result<()>
Write a transaction of changes to the backing store.
sourcefn iter<'a>(
&'a self,
col: Option<u32>
) -> Box<dyn Iterator<Item = (Box<[u8]>, Box<[u8]>)> + 'a>
fn iter<'a>(
&'a self,
col: Option<u32>
) -> Box<dyn Iterator<Item = (Box<[u8]>, Box<[u8]>)> + 'a>
Iterate over flushed data for a given column.
sourcefn iter_from_prefix<'a>(
&'a self,
col: Option<u32>,
prefix: &'a [u8]
) -> Box<dyn Iterator<Item = (Box<[u8]>, Box<[u8]>)> + 'a>
fn iter_from_prefix<'a>(
&'a self,
col: Option<u32>,
prefix: &'a [u8]
) -> Box<dyn Iterator<Item = (Box<[u8]>, Box<[u8]>)> + 'a>
Iterate over flushed data for a given column, starting from a given prefix.
sourcefn 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.
sourcefn transaction(&self) -> DBTransaction
fn transaction(&self) -> DBTransaction
Helper to create a new transaction.
Auto Trait Implementations
impl !RefUnwindSafe for Database
impl Send for Database
impl Sync for Database
impl Unpin for Database
impl UnwindSafe for Database
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more