[][src]Module bdk::database::any

Runtime-checked database types

This module provides the implementation of AnyDatabase which allows switching the inner Database type at runtime.

Example

In this example, wallet_memory and wallet_sled have the same type of Wallet<OfflineBlockchain, AnyDatabase>.

let memory = MemoryDatabase::default().into();
let wallet_memory: OfflineWallet<AnyDatabase> =
    Wallet::new_offline("...", None, Network::Testnet, memory)?;

let sled = sled::open("my-database")?.open_tree("default_tree")?.into();
let wallet_sled: OfflineWallet<AnyDatabase> =
    Wallet::new_offline("...", None, Network::Testnet, sled)?;

When paired with the use of ConfigurableDatabase, it allows creating wallets with any database supported using a single line of code:

let config = serde_json::from_str("...")?;
let database = AnyDatabase::from_config(&config)?;
let wallet: OfflineWallet<_> = Wallet::new_offline("...", None, Network::Testnet, database)?;

Structs

SledDbConfiguration

Configuration type for a sled::Tree database

Enums

AnyBatch

Type that contains any of the BatchDatabase::Batch types defined by the library

AnyDatabase

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

AnyDatabaseConfig

Type that can contain any of the database configurations defined by the library