cleaned up code, condensed code and fixed a couple of things

This commit is contained in:
DJMrTV 2025-01-26 23:21:35 +01:00
commit 38bcad37bd
10 changed files with 178 additions and 95 deletions

View file

@ -1 +1,27 @@
pub mod auth;
pub mod auth;
pub mod server;
#[macro_export]
macro_rules! define_protocol {
($id:literal => {$($func_id:literal => $func:path),*} ) => {
pub fn protocol(rmcmessage: &RMCMessage) -> Option<RMCResponse>{
if rmcmessage.protocol_id != $id{
return None;
}
let response_result = match rmcmessage.method_id{
$(
$func_id => $func(rmcmessage),
),*
_ => {
error!("invalid method id sent to protocol {}: {:?}", $id, rmcmessage.method_id);
rmcmessage.error_result_with_code(ErrorCode::Core_NotImplemented)
}
};
Some(RMCResponse{
protocol_id: $id,
response_result
})
}
};
}