Struct parity_db::Db

source ·
pub struct Db { /* private fields */ }
Expand description

Database instance.

Implementations§

source§

impl Db

source

pub fn open(options: &Options) -> Result<Db>

Open the database with given options. An error will be returned if the database does not exist.

source

pub fn open_or_create(options: &Options) -> Result<Db>

Open the database using given options. If the database does not exist it will be created empty.

source

pub fn open_read_only(options: &Options) -> Result<Db>

Open an existing database in read-only mode.

source

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.

source

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.

source

pub fn iter(&self, col: ColId) -> Result<BTreeIterator<'_>>

Iterate over all ordered key-value pairs. Only supported for columns configured with btree_indexed.

source

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.

source

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.

source

pub fn num_columns(&self) -> u8

Returns the number of columns in the database.

source

pub fn iter_column_while( &self, c: ColId, f: impl FnMut(ValueIterState) -> 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. Unlike get the iteration may not include changes made in recent commit calls.

source

pub fn write_stats_text( &self, writer: &mut impl Write, column: Option<u8>, ) -> Result<()>

Dump full database stats to the text output.

source

pub fn clear_stats(&self, column: Option<u8>) -> Result<()>

Reset internal database statistics for the database or specified column.

source

pub fn dump(&self, check_param: CheckOptions) -> Result<()>

Print database contents in text form to stderr.

source

pub fn stats(&self) -> StatSummary

Get database statistics.

source

pub fn add_column( options: &mut Options, new_column_options: ColumnOptions, ) -> Result<()>

Add a new column with options specified by new_column_options.

source

pub fn drop_last_column(options: &mut Options) -> Result<()>

Remove last column from the database. Db must be close when called.

source

pub fn reset_column( options: &mut Options, index: u8, new_options: Option<ColumnOptions>, ) -> Result<()>

Truncate a column from the database, optionally changing its options. Db must be close when called.

Trait Implementations§

source§

impl Drop for Db

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Db

§

impl !RefUnwindSafe for Db

§

impl Send for Db

§

impl Sync for Db

§

impl Unpin for Db

§

impl !UnwindSafe for Db

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> 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> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V