Enum AnyDatabase

Source
pub enum AnyDatabase {
    Memory(MemoryDatabase),
    Sled(Tree),
    Sqlite(SqliteDatabase),
}
Expand description

Type that can contain any of the Database types defined by the library

It allows switching database type at runtime.

See this module’s documentation for a usage example.

Variants§

§

Memory(MemoryDatabase)

In-memory ephemeral database

§

Sled(Tree)

Available on crate feature key-value-db only.

Simple key-value embedded database based on sled

§

Sqlite(SqliteDatabase)

Available on crate feature sqlite only.

Sqlite embedded database using rusqlite

Trait Implementations§

Source§

impl BatchDatabase for AnyDatabase

Source§

type Batch = AnyBatch

Container for the operations
Source§

fn begin_batch(&self) -> Self::Batch

Create a new batch container
Source§

fn commit_batch(&mut self, batch: Self::Batch) -> Result<(), Error>

Consume and apply a batch of operations
Source§

impl BatchOperations for AnyDatabase

Source§

fn set_script_pubkey( &mut self, script: &Script, keychain: KeychainKind, child: u32, ) -> Result<(), Error>

Store a script_pubkey along with its keychain and child number.
Source§

fn set_utxo(&mut self, utxo: &LocalUtxo) -> Result<(), Error>

Store a LocalUtxo
Source§

fn set_raw_tx(&mut self, transaction: &Transaction) -> Result<(), Error>

Store a raw transaction
Source§

fn set_tx(&mut self, transaction: &TransactionDetails) -> Result<(), Error>

Store the metadata of a transaction
Source§

fn set_last_index( &mut self, keychain: KeychainKind, value: u32, ) -> Result<(), Error>

Store the last derivation index for a given keychain.
Source§

fn set_sync_time(&mut self, sync_time: SyncTime) -> Result<(), Error>

Store the sync time
Source§

fn del_script_pubkey_from_path( &mut self, keychain: KeychainKind, child: u32, ) -> Result<Option<ScriptBuf>, Error>

Delete a script_pubkey given the keychain and its child number.
Source§

fn del_path_from_script_pubkey( &mut self, script: &Script, ) -> Result<Option<(KeychainKind, u32)>, Error>

Delete the data related to a specific script_pubkey, meaning the keychain and the child number.
Source§

fn del_utxo(&mut self, outpoint: &OutPoint) -> Result<Option<LocalUtxo>, Error>

Delete a LocalUtxo given its OutPoint
Source§

fn del_raw_tx(&mut self, txid: &Txid) -> Result<Option<Transaction>, Error>

Delete a raw transaction given its Txid
Source§

fn del_tx( &mut self, txid: &Txid, include_raw: bool, ) -> Result<Option<TransactionDetails>, Error>

Delete the metadata of a transaction and optionally the raw transaction itself
Source§

fn del_last_index( &mut self, keychain: KeychainKind, ) -> Result<Option<u32>, Error>

Delete the last derivation index for a keychain.
Source§

fn del_sync_time(&mut self) -> Result<Option<SyncTime>, Error>

Reset the sync time to None Read more
Source§

impl ConfigurableDatabase for AnyDatabase

Source§

type Config = AnyDatabaseConfig

Type that contains the configuration
Source§

fn from_config(config: &Self::Config) -> Result<Self, Error>

Create a new instance given a configuration
Source§

impl Database for AnyDatabase

Source§

fn check_descriptor_checksum<B: AsRef<[u8]>>( &mut self, keychain: KeychainKind, bytes: B, ) -> Result<(), Error>

Read and checks the descriptor checksum for a given keychain. Read more
Source§

fn iter_script_pubkeys( &self, keychain: Option<KeychainKind>, ) -> Result<Vec<ScriptBuf>, Error>

Return the list of script_pubkeys
Source§

fn iter_utxos(&self) -> Result<Vec<LocalUtxo>, Error>

Return the list of LocalUtxos
Source§

fn iter_raw_txs(&self) -> Result<Vec<Transaction>, Error>

Return the list of raw transactions
Source§

fn iter_txs(&self, include_raw: bool) -> Result<Vec<TransactionDetails>, Error>

Return the list of transactions metadata
Source§

fn get_script_pubkey_from_path( &self, keychain: KeychainKind, child: u32, ) -> Result<Option<ScriptBuf>, Error>

Fetch a script_pubkey given the child number of a keychain.
Source§

fn get_path_from_script_pubkey( &self, script: &Script, ) -> Result<Option<(KeychainKind, u32)>, Error>

Fetch the keychain and child number of a given script_pubkey
Source§

fn get_utxo(&self, outpoint: &OutPoint) -> Result<Option<LocalUtxo>, Error>

Fetch a LocalUtxo given its OutPoint
Source§

fn get_raw_tx(&self, txid: &Txid) -> Result<Option<Transaction>, Error>

Fetch a raw transaction given its Txid
Source§

fn get_tx( &self, txid: &Txid, include_raw: bool, ) -> Result<Option<TransactionDetails>, Error>

Fetch the transaction metadata and optionally also the raw transaction
Source§

fn get_last_index(&self, keychain: KeychainKind) -> Result<Option<u32>, Error>

Return the last derivation index for a keychain.
Source§

fn get_sync_time(&self) -> Result<Option<SyncTime>, Error>

Return the sync time, if present
Source§

fn increment_last_index(&mut self, keychain: KeychainKind) -> Result<u32, Error>

Increment the last derivation index for a keychain and return it Read more
Source§

impl Debug for AnyDatabase

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<MemoryDatabase> for AnyDatabase

Source§

fn from(inner: MemoryDatabase) -> Self

Converts to this type from the input type.
Source§

impl From<SqliteDatabase> for AnyDatabase

Source§

fn from(inner: SqliteDatabase) -> Self

Converts to this type from the input type.
Source§

impl From<Tree> for AnyDatabase

Source§

fn from(inner: Tree) -> Self

Converts to this type from the input type.

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> 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, 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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T