firebase_rs_sdk/util/
runtime.rs1#[cfg(not(target_arch = "wasm32"))]
4pub mod native {
5 use std::future::Future;
6 use std::sync::LazyLock;
7
8 use tokio::runtime::{Builder, Runtime};
9
10 static RUNTIME: LazyLock<Runtime> = LazyLock::new(|| {
11 Builder::new_current_thread()
12 .enable_all()
13 .build()
14 .expect("failed to build tokio runtime")
15 });
16
17 pub fn block_on<F, T>(future: F) -> T
19 where
20 F: Future<Output = T> + 'static,
21 T: 'static,
22 {
23 RUNTIME.block_on(future)
24 }
25}
26
27#[cfg(target_arch = "wasm32")]
28pub mod native {
29 use std::future::Future;
30
31 pub fn block_on<F, T>(_future: F) -> T
33 where
34 F: Future<Output = T>,
35 {
36 panic!("blocking on futures is unsupported in wasm builds")
37 }
38}
39
40pub use native::block_on;