#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate log;
#[cfg(test)]
extern crate tempdir;
#[macro_use]
extern crate bitflags;
#[macro_use]
extern crate serde_derive;
#[cfg(feature = "http")]
extern crate actix_web;
#[cfg(test)]
extern crate serde_json;
#[macro_use]
extern crate derivative;
pub mod sync {
pub type RwLock<T> = parking_lot::RwLock<T>;
pub type Mutex<T> = parking_lot::Mutex<T>;
}
#[macro_export]
macro_rules! trace_lock {
( $x:expr ) => {
{
let v = $x.lock();
v
}
}
}
#[macro_export]
macro_rules! trace_read_lock {
( $x:expr ) => {
{
let v = $x.read();
v
}
}
}
#[macro_export]
macro_rules! trace_write_lock {
( $x:expr ) => {
{
let v = $x.write();
v
}
}
}
#[cfg(feature = "client")]
pub mod client;
#[cfg(feature = "console-logging")]
pub mod console_logging;
pub mod core;
pub mod crypto;
#[cfg(feature = "server")]
pub mod server;
pub mod types;
#[cfg(test)]
fn from_hex(v: &str) -> Vec<u8> {
let mut b = Vec::with_capacity(v.len() / 2);
let mut modulus = 0;
let mut buf = 0;
for (idx, byte) in v.bytes().enumerate() {
buf <<= 4;
match byte {
b'A'..=b'F' => buf |= byte - b'A' + 10,
b'a'..=b'f' => buf |= byte - b'a' + 10,
b'0'..=b'9' => buf |= byte - b'0',
b' ' | b'\r' | b'\n' | b'\t' => {
buf >>= 4;
continue;
}
_ => {
let ch = v[idx..].chars().next().unwrap();
panic!("Invalid hex character {} at {}", ch, idx);
}
}
modulus += 1;
if modulus == 2 {
modulus = 0;
b.push(buf);
}
}
match modulus {
0 => b.into_iter().collect(),
_ => panic!("Invalid hex length"),
}
}
mod prelude {
#[cfg(feature = "client")]
pub use crate::client::prelude::*;
pub use crate::core::prelude::*;
#[cfg(feature = "server")]
pub use crate::server::prelude::*;
}