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
use super::*;
pub enum SearchBy{
Range(u32, u32),
Txid(&'static str),
Address(&'static str)
}
pub fn str_to_hex(utf8: &str) -> String {
let strs: Vec<String> = utf8.as_bytes()
.iter()
.map(|b| format!("{:02X}", b))
.collect();
strs.join("")
}
pub fn fetch<F, R, E>(fut: F)-> Result<R, E>
where
F: Send + 'static + Future<Item = R, Error = E>,
R: Send + 'static,
E: Send + 'static,
{
let mut runtime = Runtime::new().expect("Unable to create a tokio runtime");
runtime.block_on(fut)
}
pub fn to_static_str(s: String) -> &'static str {
Box::leak(s.into_boxed_str())
}