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
#![deny(unused_extern_crates)]
#![warn(missing_docs, rust_2018_idioms, unreachable_pub)]
#[macro_use]
extern crate serde;
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 builder;
pub mod client;
pub mod error;
pub mod node;
pub mod node_manager;
#[cfg(feature = "storage")]
#[cfg_attr(docsrs, doc(cfg(feature = "storage")))]
pub mod storage;
pub use bee_common as common;
pub use bee_message;
pub use bee_pow as pow;
pub use bee_rest_api;
pub use builder::ClientBuilder;
pub use client::*;
pub use crypto::{self, keys::slip10::Seed};
pub use error::*;
#[cfg(feature = "mqtt")]
pub use node::Topic;
pub use node::{OutputType, OutputsOptions as AddressOutputsOptions};
#[cfg(feature = "storage")]
pub use storage::*;
pub use url::Url;
#[cfg(feature = "mqtt")]
mod async_runtime {
use once_cell::sync::OnceCell;
use tokio::runtime::Runtime;
use std::sync::Mutex;
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 runtim")));
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 runtim")));
runtime.lock().expect("Failed to lock the runtime.").spawn(future);
}
}