lib.rs 697 B

12345678910111213141516171819202122232425262728
  1. #[cfg(all(target_arch = "wasm32", feature = "blocking"))]
  2. compile_error!("`blocking` feature can't be enabled for WASM targets");
  3. #[cfg(feature = "blocking")]
  4. use once_cell::sync::Lazy;
  5. #[cfg(feature = "blocking")]
  6. use tokio::runtime::Runtime;
  7. #[cfg(feature = "blocking")]
  8. use futures_util::Future;
  9. #[cfg(feature = "wallet")]
  10. pub mod client;
  11. #[cfg(feature = "mint")]
  12. pub mod mint;
  13. #[cfg(feature = "wallet")]
  14. pub mod wallet;
  15. pub use cashu::{self, *};
  16. #[cfg(feature = "blocking")]
  17. static RUNTIME: Lazy<Runtime> = Lazy::new(|| Runtime::new().expect("Can't start Tokio runtime"));
  18. #[cfg(feature = "blocking")]
  19. pub fn block_on<F: Future>(future: F) -> F::Output {
  20. RUNTIME.block_on(future)
  21. }