#![deny(missing_docs)]
#![deny(clippy::large_futures)]
#[doc(hidden)]
pub use async_trait::async_trait;
pub mod abi;
#[cfg(not(target_arch = "wasm32"))]
pub mod command;
pub mod crypto;
pub mod data_types;
mod graphql;
pub mod identifiers;
mod limited_writer;
pub mod ownership;
#[cfg(not(target_arch = "wasm32"))]
pub mod port;
#[cfg(with_metrics)]
pub mod prometheus_util;
#[cfg(not(chain))]
pub mod task;
pub mod time;
#[cfg_attr(web, path = "tracing_web.rs")]
pub mod tracing;
#[cfg(test)]
mod unit_tests;
pub use graphql::BcsHexParseError;
#[doc(hidden)]
pub use {async_graphql, bcs, hex};
#[macro_export]
macro_rules! ensure {
($cond:expr, $e:expr) => {
if !($cond) {
return Err($e.into());
}
};
}
pub fn hex_debug<T: AsRef<[u8]>>(bytes: &T, f: &mut std::fmt::Formatter) -> std::fmt::Result {
const ELIDE_AFTER: usize = 16;
let bytes = bytes.as_ref();
if bytes.len() <= 2 * ELIDE_AFTER {
write!(f, "{}", hex::encode(bytes))?;
} else {
write!(
f,
"{}..{}",
hex::encode(&bytes[..ELIDE_AFTER]),
hex::encode(&bytes[(bytes.len() - ELIDE_AFTER)..])
)?;
}
Ok(())
}