racme/src/macros.rs

37 Zeilen
921 B
Rust

use macro_rules_attribute::attribute_alias;
#[allow(unused_macros)]
macro_rules! match_error {
($result:expr =>Err($errorname:ident)-> $errormessage:literal $(, $returntype:expr)?) => {
match $result {
Ok(ok) => ok,
Err($errorname) => {
::log::error!($errormessage);
return $($returntype)*;
},
}
};
}
#[allow(unused_macros)]
macro_rules! attr_function {
(
$visibility:vis $attr:ident $($items:ident).* => $type:ty
)=>{
$visibility fn $attr(&self) -> $type {
self$(.$items).*.$attr.clone()
}
}
}
attribute_alias! {
#[apply(ConfigFile!)] = #[derive(::serde::Deserialize, ::schemars::JsonSchema)];
#[apply(Hashable!)] = #[derive(Eq,Hash)];
#[apply(DefDer!)] = #[derive(Debug, Clone)];
}
#[allow(unused_imports)]
pub(crate) use {
attr_function,
match_error,
};