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

Expand description

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<(), AnyDatabase>.

let memory = MemoryDatabase::default();
let wallet_memory = Wallet::new_offline("...", None, Network::Testnet, memory)?;

let sled = sled::open("my-database")?.open_tree("default_tree")?;
let wallet_sled = 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 = Wallet::new_offline("...", None, Network::Testnet, database)?;

Structs

Configuration type for a [sled::Tree] database

Enums

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

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

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