Struct parity_db::Db

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

Implementations§

source§

impl Db

source

pub fn with_columns(path: &Path, num_columns: u8) -> Result<Db>

source

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

Open the database with given options.

source

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

Create the database using given options.

source

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

Read the database using given options

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(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.

source

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

source

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

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.

Trait Implementations§

source§

impl Drop for Db

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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 Twhere V: MultiLane<T>,

source§

fn vzip(self) -> V