#[macro_export]
macro_rules! define_protocol {
(
$(#[$meta:meta])*
name: $name:ident,
transport: $transport:expr,
identify: |$data:ident| $body:expr
) => {
$(#[$meta])*
pub struct $name;
impl $crate::protocols::RefractiumProtocol for $name {
#[inline]
fn identify(&self, $data: &[u8]) -> Option<$crate::protocols::ProtocolMatch> {
if $body {
return Some($crate::protocols::ProtocolMatch {
name: stringify!($name).to_lowercase(),
metadata: None,
});
}
None
}
fn name(&self) -> &'static str {
stringify!($name)
}
fn transport(&self) -> $crate::core::types::Transport {
$transport
}
}
};
}
#[macro_export]
macro_rules! refractium_debug {
($($arg:tt)*) => {
{
#[cfg(feature = "logging")]
tracing::info!($($arg)*);
}
};
}
#[macro_export]
macro_rules! refractium_error {
($($arg:tt)*) => {
{
#[cfg(feature = "logging")]
tracing::error!($($arg)*);
}
};
}