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
impl DatabaseHandle
Sourcepub fn new(args: DatabaseHandleArgs<'_>) -> Result<Self, Error>
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.
Sourcepub fn current_root_hash(&self) -> Option<HashKey>
pub fn current_root_hash(&self) -> Option<HashKey>
Sourcepub fn get_latest(&self, key: impl KeyType) -> Result<Option<Box<[u8]>>, Error>
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.
Sourcepub fn create_batch<'a>(
&self,
values: impl AsRef<[BatchOp<'a>]> + 'a,
) -> Result<Option<HashKey>, Error>
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.
Sourcepub fn get_revision(
&self,
root: HashKey,
) -> Result<GetRevisionResult<'_>, Error>
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.
Sourcepub fn reconstruct_from_view<'db>(
&'db self,
parent: &NodeStore<Committed, FileBacked>,
batch: impl IntoBatchIter,
) -> Result<ReconstructedView<'db>, Error>
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.
Sourcepub fn apply_change_proof_to_parent(
&self,
start_hash: HashKey,
change_proof: &FrozenChangeProof,
) -> Result<CreateProposalResult<'_>, Error>
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.
Trait Implementations§
Source§impl<'db> CView<'db> for &'db DatabaseHandle
impl<'db> CView<'db> for &'db DatabaseHandle
Source§fn handle(&self) -> &'db DatabaseHandle
fn handle(&self) -> &'db DatabaseHandle
Source§fn create_proposal(
self,
values: impl IntoBatchIter,
) -> Result<Proposal<'db>, Error>
fn create_proposal( self, values: impl IntoBatchIter, ) -> Result<Proposal<'db>, Error>
firewood::db::Proposal with the provided key-value pairs. Read moreSource§fn create_proposal_handle(
self,
values: impl IntoBatchIter,
) -> Result<CreateProposalResult<'db>, Error>where
Self: Sized,
fn create_proposal_handle(
self,
values: impl IntoBatchIter,
) -> Result<CreateProposalResult<'db>, Error>where
Self: Sized,
ProposalHandle from the values and return it with timing
information. Read moreAuto Trait Implementations§
impl !Freeze for DatabaseHandle
impl !RefUnwindSafe for DatabaseHandle
impl !UnwindSafe for DatabaseHandle
impl Send for DatabaseHandle
impl Sync for DatabaseHandle
impl Unpin for DatabaseHandle
impl UnsafeUnpin for DatabaseHandle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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