pub struct Db { /* private fields */ }
Implementations§
source§impl Db
impl Db
pub fn with_columns(path: &Path, num_columns: u8) -> Result<Db>
sourcepub fn open_or_create(options: &Options) -> Result<Db>
pub fn open_or_create(options: &Options) -> Result<Db>
Create the database using given options.
sourcepub fn open_read_only(options: &Options) -> Result<Db>
pub fn open_read_only(options: &Options) -> Result<Db>
Read the database using given options
sourcepub fn get(&self, col: ColId, key: &[u8]) -> Result<Option<Value>>
pub fn get(&self, col: ColId, key: &[u8]) -> Result<Option<Value>>
Get a value in a specified column by key. Returns None
if the key does not exist.
sourcepub fn get_size(&self, col: ColId, key: &[u8]) -> Result<Option<u32>>
pub fn get_size(&self, col: ColId, key: &[u8]) -> Result<Option<u32>>
Get value size by key. Returns None
if the key does not exist.
sourcepub fn iter(&self, col: ColId) -> Result<BTreeIterator<'_>>
pub fn iter(&self, col: ColId) -> Result<BTreeIterator<'_>>
Iterate over all ordered key-value pairs. Only supported for columns configured with
btree_indexed
.
sourcepub fn commit<I, K>(&self, tx: I) -> Result<()>where
I: IntoIterator<Item = (ColId, K, Option<Value>)>,
K: AsRef<[u8]>,
pub fn commit<I, K>(&self, tx: I) -> Result<()>where I: IntoIterator<Item = (ColId, K, Option<Value>)>, K: AsRef<[u8]>,
Commit a set of changes to the database.
sourcepub fn commit_changes<I>(&self, tx: I) -> Result<()>where
I: IntoIterator<Item = (ColId, Operation<Vec<u8>, Vec<u8>>)>,
pub fn commit_changes<I>(&self, tx: I) -> Result<()>where I: IntoIterator<Item = (ColId, Operation<Vec<u8>, Vec<u8>>)>,
Commit a set of changes to the database.
sourcepub fn num_columns(&self) -> u8
pub fn num_columns(&self) -> u8
Returns the number of columns in the database.
sourcepub fn iter_column_while(
&self,
c: ColId,
f: impl FnMut(IterState) -> bool
) -> Result<()>
pub fn iter_column_while( &self, c: ColId, f: impl FnMut(IterState) -> bool ) -> Result<()>
Iterate a column and call a function for each value. This is only supported for columns with
btree_index
set to false
. Iteration order is unspecified. Note that the
key
field in the state is the hash of the original key.
Unlinke get
the iteration may not include changes made in recent commit
calls.
pub fn write_stats_text( &self, writer: &mut impl Write, column: Option<u8> ) -> Result<()>
pub fn clear_stats(&self, column: Option<u8>) -> Result<()>
sourcepub fn dump(&self, check_param: CheckOptions) -> Result<()>
pub fn dump(&self, check_param: CheckOptions) -> Result<()>
Print database contents in text form to stderr.
sourcepub fn stats(&self) -> StatSummary
pub fn stats(&self) -> StatSummary
Get database statistics.
sourcepub fn add_column(
options: &mut Options,
new_column_options: ColumnOptions
) -> Result<()>
pub fn add_column( options: &mut Options, new_column_options: ColumnOptions ) -> Result<()>
Add a new column with options specified by new_column_options
.