Module bdk::database::any [−][src]
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
SledDbConfiguration | Configuration type for a |
Enums
AnyBatch | Type that contains any of the |
AnyDatabase | Type that can contain any of the |
AnyDatabaseConfig | Type that can contain any of the database configurations defined by the library |