1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#![deny(unused_extern_crates)]
#![warn(missing_docs, rust_2018_idioms, unreachable_pub)]
#[macro_use]
extern crate serde;
#[cfg(feature = "mqtt")]
macro_rules! lazy_static {
($init:expr => $type:ty) => {{
static mut VALUE: Option<$type> = None;
static INIT: std::sync::Once = std::sync::Once::new();
INIT.call_once(|| unsafe { VALUE = Some($init) });
unsafe { VALUE.as_ref() }.expect("failed to get lazy static value")
}};
}
pub mod api;
pub mod client;
pub mod constants;
pub mod db;
pub mod error;
#[cfg(feature = "message_interface")]
pub mod message_interface;
pub mod node_api;
pub mod node_manager;
pub mod secret;
#[cfg(feature = "stronghold")]
pub mod stronghold;
pub mod utils;
pub use bee_api_types as api_types;
pub use bee_block as block;
pub use bee_pow as pow;
pub use crypto::{self, keys::slip10::Seed};
pub use packable;
pub use url::Url;
#[cfg(feature = "mqtt")]
pub use self::node_api::mqtt::*;
pub use self::{client::*, error::*, node_api::core::routes::NodeInfoWrapper, utils::*};
#[cfg(feature = "mqtt")]
mod async_runtime {
use std::sync::Mutex;
use once_cell::sync::OnceCell;
use tokio::runtime::Runtime;
static RUNTIME: OnceCell<Mutex<Runtime>> = OnceCell::new();
pub(crate) fn block_on<C: futures::Future>(cb: C) -> C::Output {
let runtime = RUNTIME.get_or_init(|| Mutex::new(Runtime::new().expect("failed to create Tokio runtime")));
runtime.lock().expect("failed to lock the runtime.").block_on(cb)
}
pub(crate) fn spawn<F>(future: F)
where
F: futures::Future + Send + 'static,
F::Output: Send + 'static,
{
let runtime = RUNTIME.get_or_init(|| Mutex::new(Runtime::new().expect("failed to create Tokio runtime")));
runtime.lock().expect("failed to lock the runtime.").spawn(future);
}
}