refactor: redb as feature

This commit is contained in:
thesimplekid
2024-01-02 16:40:51 +00:00
parent 8faf8491f0
commit a4b409ee87
3 changed files with 11 additions and 3 deletions

View File

@@ -17,6 +17,7 @@ gloo = ["dep:gloo"]
all-nuts = ["nut07", "nut08"]
nut07 = ["cashu/nut07"]
nut08 = ["cashu/nut08"]
redb = ["dep:redb"]
[dependencies]
@@ -35,7 +36,7 @@ gloo = { version = "0.10.0", optional = true, features = ["net"] }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio = { workspace = true, features = ["rt-multi-thread", "time", "macros", "sync"] }
minreq = { version = "2.7.0", optional = true, features = ["json-using-serde", "https"] }
redb = "1.4.0"
redb = { version = "1.4.0", optional = true }
[target.'cfg(target_arch = "wasm32")'.dependencies]
tokio = { workspace = true, features = ["rt", "macros", "sync", "time"] }

View File

@@ -20,7 +20,7 @@ pub mod wallet;
pub use bip39::Mnemonic;
pub use cashu::{self, *};
#[cfg(not(target_arch = "wasm32"))]
#[cfg(all(not(target_arch = "wasm32"), feature = "redb"))]
pub use localstore::redb_store::RedbLocalStore;
#[cfg(feature = "blocking")]

View File

@@ -1,6 +1,6 @@
mod memory;
#[cfg(not(target_arch = "wasm32"))]
#[cfg(all(not(target_arch = "wasm32"), feature = "redb"))]
pub mod redb_store;
use std::collections::HashMap;
@@ -13,18 +13,25 @@ use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error {
#[cfg(all(not(target_arch = "wasm32"), feature = "redb"))]
#[error("`{0}`")]
Redb(#[from] redb::Error),
#[cfg(all(not(target_arch = "wasm32"), feature = "redb"))]
#[error("`{0}`")]
Database(#[from] redb::DatabaseError),
#[cfg(all(not(target_arch = "wasm32"), feature = "redb"))]
#[error("`{0}`")]
Transaction(#[from] redb::TransactionError),
#[cfg(all(not(target_arch = "wasm32"), feature = "redb"))]
#[error("`{0}`")]
Commit(#[from] redb::CommitError),
#[cfg(all(not(target_arch = "wasm32"), feature = "redb"))]
#[error("`{0}`")]
Table(#[from] redb::TableError),
#[cfg(all(not(target_arch = "wasm32"), feature = "redb"))]
#[error("`{0}`")]
Storage(#[from] redb::StorageError),
#[cfg(all(not(target_arch = "wasm32"), feature = "redb"))]
#[error("`{0}`")]
Serde(#[from] serde_json::Error),
}