1#[macro_use]
2extern crate lazy_static;
3#[macro_use]
4extern crate log;
5#[cfg(test)]
6extern crate tempdir;
7#[macro_use]
8extern crate bitflags;
9#[macro_use]
10extern crate serde_derive;
11#[cfg(feature = "http")]
12extern crate actix_web;
13#[cfg(test)]
14extern crate serde_json;
15#[macro_use]
16extern crate derivative;
17
18pub mod sync {
21 pub type RwLock<T> = parking_lot::RwLock<T>;
22 pub type Mutex<T> = parking_lot::Mutex<T>;
23}
24
25#[macro_export]
28macro_rules! trace_lock {
29 ( $x:expr ) => {
30 {
31let v = $x.lock();
34v
36 }
37 }
38}
39
40#[macro_export]
42macro_rules! trace_read_lock {
43 ( $x:expr ) => {
44 {
45let v = $x.read();
48v
50 }
51 }
52}
53
54#[macro_export]
56macro_rules! trace_write_lock {
57 ( $x:expr ) => {
58 {
59let v = $x.write();
62v
64 }
65 }
66}
67
68#[cfg(feature = "client")]
69pub mod client;
70#[cfg(feature = "console-logging")]
71pub mod console_logging;
72pub mod core;
73pub mod crypto;
74#[cfg(feature = "server")]
75pub mod server;
76pub mod types;
77
78#[cfg(test)]
83fn from_hex(v: &str) -> Vec<u8> {
84 let mut b = Vec::with_capacity(v.len() / 2);
86 let mut modulus = 0;
87 let mut buf = 0;
88
89 for (idx, byte) in v.bytes().enumerate() {
90 buf <<= 4;
91
92 match byte {
93 b'A'..=b'F' => buf |= byte - b'A' + 10,
94 b'a'..=b'f' => buf |= byte - b'a' + 10,
95 b'0'..=b'9' => buf |= byte - b'0',
96 b' ' | b'\r' | b'\n' | b'\t' => {
97 buf >>= 4;
98 continue;
99 }
100 _ => {
101 let ch = v[idx..].chars().next().unwrap();
102 panic!("Invalid hex character {} at {}", ch, idx);
103 }
104 }
105
106 modulus += 1;
107 if modulus == 2 {
108 modulus = 0;
109 b.push(buf);
110 }
111 }
112
113 match modulus {
114 0 => b.into_iter().collect(),
115 _ => panic!("Invalid hex length"),
116 }
117}
118
119mod prelude {
120 #[cfg(feature = "client")]
121 pub use crate::client::prelude::*;
122 pub use crate::core::prelude::*;
123 #[cfg(feature = "server")]
124 pub use crate::server::prelude::*;
125}