Skip to main content

DatabaseHandle

Struct DatabaseHandle 

Source
pub struct DatabaseHandle { /* private fields */ }
Expand description

A handle to the database, returned by fwd_open_db.

These handles are passed to the other FFI functions.

Implementations§

Source§

impl DatabaseHandle

Source

pub fn new(args: DatabaseHandleArgs<'_>) -> Result<Self, Error>

Creates a new database handle from the given arguments.

§Errors

If the path is empty, or if the configuration is invalid, this will return an error.

Source

pub fn current_root_hash(&self) -> Option<HashKey>

Returns the current root hash of the database.

§Errors

Never errors.

Source

pub fn get_latest(&self, key: impl KeyType) -> Result<Option<Box<[u8]>>, Error>

Returns a value from the database for the given key from the latest root hash.

§Errors

An error is returned if there was an i/o error while reading the value.

Source

pub fn create_batch<'a>( &self, values: impl AsRef<[BatchOp<'a>]> + 'a, ) -> Result<Option<HashKey>, Error>

Creates and commits a proposal with the given values.

§Errors

An error is returned if the proposal could not be created.

Source

pub fn get_revision( &self, root: HashKey, ) -> Result<GetRevisionResult<'_>, Error>

Returns an owned handle to the revision corresponding to the provided root hash.

§Errors

Returns an error if could not get the view from underlying database for the specified root hash, for example when the revision does not exist or an I/O error occurs while accessing the database.

Source

pub fn reconstruct_from_view<'db>( &'db self, parent: &NodeStore<Committed, FileBacked>, batch: impl IntoBatchIter, ) -> Result<ReconstructedView<'db>, Error>

Reconstructs a view on top of an existing historical node store.

§Errors

Returns an error if reconstruction fails.

Source

pub fn apply_change_proof_to_parent( &self, start_hash: HashKey, change_proof: &FrozenChangeProof, ) -> Result<CreateProposalResult<'_>, Error>

Applies the BatchOps of a change proof to the parent.

§Errors

Returns a LatestIsEmpty error if the trie is empty. A range proof should be used in this case.

Source

pub fn dump_to_string(&self) -> Result<String, Error>

Dumps the Trie structure of the latest revision to a DOT (Graphviz) format string.

§Errors

An error is returned if there was an i/o error while dumping the trie.

Source

pub fn close(self) -> Result<(), Error>

Closes the database gracefully.

§Errors

An error is returned if the persistence background thread panicked or errored during execution.

Trait Implementations§

Source§

impl<'db> CView<'db> for &'db DatabaseHandle

Source§

fn handle(&self) -> &'db DatabaseHandle

Returns a reference to the database handle that is ultimately used to create the proposal. For the database handle, this returns itself. For, a proposal handle, this returns the handle that was used to create the proposal.
Source§

fn create_proposal( self, values: impl IntoBatchIter, ) -> Result<Proposal<'db>, Error>

Create a firewood::db::Proposal with the provided key-value pairs. Read more
Source§

fn create_proposal_handle( self, values: impl IntoBatchIter, ) -> Result<CreateProposalResult<'db>, Error>
where Self: Sized,

Create a ProposalHandle from the values and return it with timing information. Read more
Source§

impl Debug for DatabaseHandle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

Source§

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

Source§

impl<T> ValueSize for T

Source§

fn value_size(&self) -> usize

The size of this value in bytes, excluding allocated data. Read more
Source§

fn value_size_sum_iter<'item>(iterator: impl Iterator<Item = &'item T>) -> usize
where T: 'item,

The total sum of the sizes of all values in the given iterator, in bytes. This is default-implemented by computing ValueSize::value_size on every element and summing them. For Sized types, a more potentially efficient implementation using Iterator::count is provided. If you are implementing this trait manually, it is unlikely to be more efficient to provide a manual implementation here. Read more
Source§

fn value_size_sum_exact_size_iter<'item>( iterator: impl ExactSizeIterator<Item = &'item T>, ) -> usize
where T: 'item,

The total sum of the sizes of all values in the given exact-size-iterator, in bytes. This is default-implemented by using ValueSize::value_size_sum_iter. For Sized types, a usually more efficient implementation using ExactSizeIterator::len is provided. If you are implementing this trait manually, it is unlikely to be more efficient to provide a manual implementation here. Read more