feat: split rmc off from prudp, make macros crate location independent and add tls connection setup
This commit is contained in:
parent
0a1e49d9bc
commit
9da91bb835
24 changed files with 1218 additions and 420 deletions
|
|
@ -189,7 +189,7 @@ pub fn rmc_serialize(input: TokenStream) -> TokenStream {
|
|||
|
||||
quote! {
|
||||
#pre_inner
|
||||
crate::rmc::structures::rmc_struct::write_struct(writer, #version, |mut writer|{
|
||||
splatoon_server_rust::rmc::structures::rmc_struct::write_struct(writer, #version, |mut writer|{
|
||||
#serialize_base_content
|
||||
})?;
|
||||
|
||||
|
|
@ -218,7 +218,7 @@ pub fn rmc_serialize(input: TokenStream) -> TokenStream {
|
|||
|
||||
quote! {
|
||||
#pre_inner
|
||||
Ok(crate::rmc::structures::rmc_struct::read_struct(reader, #version, move |mut reader|{
|
||||
Ok(splatoon_server_rust::rmc::structures::rmc_struct::read_struct(reader, #version, move |mut reader|{
|
||||
#deserialize_base_content
|
||||
})?)
|
||||
}
|
||||
|
|
@ -229,14 +229,14 @@ pub fn rmc_serialize(input: TokenStream) -> TokenStream {
|
|||
let ident = derive_input.ident;
|
||||
|
||||
let tokens = quote! {
|
||||
impl crate::rmc::structures::RmcSerialize for #ident{
|
||||
fn serialize(&self, writer: &mut dyn ::std::io::Write) -> crate::rmc::structures::Result<()>{
|
||||
impl splatoon_server_rust::rmc::structures::RmcSerialize for #ident{
|
||||
fn serialize(&self, writer: &mut dyn ::std::io::Write) -> splatoon_server_rust::rmc::structures::Result<()>{
|
||||
#serialize_base_content
|
||||
|
||||
|
||||
}
|
||||
|
||||
fn deserialize(reader: &mut dyn ::std::io::Read) -> crate::rmc::structures::Result<Self>{
|
||||
fn deserialize(reader: &mut dyn ::std::io::Read) -> splatoon_server_rust::rmc::structures::Result<Self>{
|
||||
#deserialize_base_content
|
||||
}
|
||||
}
|
||||
|
|
@ -367,8 +367,8 @@ pub fn rmc_struct(attr: TokenStream, input: TokenStream) -> TokenStream{
|
|||
|
||||
}
|
||||
|
||||
impl crate::rmc::protocols::RmcCallable for #struct_name{
|
||||
async fn rmc_call(&self, remote_response_connection: &crate::prudp::socket::SendingConnection, protocol_id: u16, method_id: u32, call_id: u32, rest: Vec<u8>){
|
||||
impl splatoon_server_rust::rmc::protocols::RmcCallable for #struct_name{
|
||||
async fn rmc_call(&self, remote_response_connection: &splatoon_server_rust::util::SendingBufferConnection, protocol_id: u16, method_id: u32, call_id: u32, rest: Vec<u8>){
|
||||
<Self as #ident>::rmc_call(self, remote_response_connection, protocol_id, method_id, call_id, rest).await;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ impl RmcProtocolData{
|
|||
for (param_name, param_type) in parameters{
|
||||
quote!{
|
||||
let Ok(#param_name) =
|
||||
<#param_type as crate::rmc::structures::RmcSerialize>::deserialize(
|
||||
<#param_type as splatoon_server_rust::rmc::structures::RmcSerialize>::deserialize(
|
||||
&mut cursor
|
||||
) else
|
||||
}.to_tokens(tokens);
|
||||
|
|
@ -84,7 +84,7 @@ impl RmcProtocolData{
|
|||
quote! {
|
||||
{
|
||||
log::error!(#error_msg);
|
||||
return Err(crate::rmc::response::ErrorCode::Core_InvalidArgument);
|
||||
return Err(splatoon_server_rust::rmc::response::ErrorCode::Core_InvalidArgument);
|
||||
};
|
||||
}.to_tokens(tokens)
|
||||
} else {
|
||||
|
|
@ -116,7 +116,7 @@ impl RmcProtocolData{
|
|||
quote!{
|
||||
let retval = retval?;
|
||||
let mut vec = Vec::new();
|
||||
crate::rmc::structures::RmcSerialize::serialize(&retval, &mut vec).ok();
|
||||
splatoon_server_rust::rmc::structures::RmcSerialize::serialize(&retval, &mut vec).ok();
|
||||
Ok(vec)
|
||||
}.to_tokens(tokens);
|
||||
}
|
||||
|
|
@ -126,7 +126,7 @@ impl RmcProtocolData{
|
|||
quote!{
|
||||
async fn rmc_call_proto(
|
||||
&self,
|
||||
remote_response_connection: &crate::prudp::socket::SendingConnection,
|
||||
remote_response_connection: &splatoon_server_rust::util::SendingBufferConnection,
|
||||
method_id: u32,
|
||||
call_id: u32,
|
||||
data: Vec<u8>,
|
||||
|
|
@ -165,7 +165,7 @@ impl RmcProtocolData{
|
|||
}.to_tokens(tokens);
|
||||
if self.has_returns {
|
||||
quote! {
|
||||
Err(crate::rmc::response::ErrorCode::Core_NotImplemented)
|
||||
Err(splatoon_server_rust::rmc::response::ErrorCode::Core_NotImplemented)
|
||||
}.to_tokens(tokens);
|
||||
}
|
||||
});
|
||||
|
|
@ -176,7 +176,7 @@ impl RmcProtocolData{
|
|||
|
||||
if *has_returns{
|
||||
quote!{
|
||||
crate::rmc::response::send_result(
|
||||
splatoon_server_rust::rmc::response::send_result(
|
||||
remote_response_connection,
|
||||
ret,
|
||||
#id,
|
||||
|
|
@ -209,7 +209,7 @@ impl RmcProtocolData{
|
|||
// boilerplate tokens which all raw traits need
|
||||
quote!{
|
||||
#[doc(hidden)]
|
||||
pub trait #remote_name: crate::rmc::protocols::HasRmcConnection
|
||||
pub trait #remote_name: splatoon_server_rust::rmc::protocols::HasRmcConnection
|
||||
}.to_tokens(tokens);
|
||||
|
||||
// generate the body of the raw protocol trait
|
||||
|
|
@ -247,12 +247,12 @@ impl RmcProtocolData{
|
|||
|
||||
for (param_name, param_type) in parameters{
|
||||
quote!{
|
||||
crate::result::ResultExtension::display_err_or_some(
|
||||
<#param_type as crate::rmc::structures::RmcSerialize>::serialize(
|
||||
splatoon_server_rust::result::ResultExtension::display_err_or_some(
|
||||
<#param_type as splatoon_server_rust::rmc::structures::RmcSerialize>::serialize(
|
||||
&#param_name,
|
||||
&mut cursor
|
||||
)
|
||||
).ok_or(crate::rmc::response::ErrorCode::Core_InvalidArgument)
|
||||
).ok_or(splatoon_server_rust::rmc::response::ErrorCode::Core_InvalidArgument)
|
||||
}.to_tokens(tokens);
|
||||
if self.has_returns {
|
||||
quote! {
|
||||
|
|
@ -268,25 +268,25 @@ impl RmcProtocolData{
|
|||
quote!{
|
||||
let call_id = rand::random();
|
||||
|
||||
let message = crate::rmc::message::RMCMessage{
|
||||
let message = splatoon_server_rust::rmc::message::RMCMessage{
|
||||
call_id,
|
||||
method_id: #method_id,
|
||||
protocol_id: #proto_id,
|
||||
rest_of_data: send_data
|
||||
};
|
||||
|
||||
let rmc_conn = <Self as crate::rmc::protocols::HasRmcConnection>::get_connection(self);
|
||||
let rmc_conn = <Self as splatoon_server_rust::rmc::protocols::HasRmcConnection>::get_connection(self);
|
||||
}.to_tokens(tokens);
|
||||
|
||||
if *has_returns{
|
||||
quote!{
|
||||
crate::result::ResultExtension::display_err_or_some(
|
||||
splatoon_server_rust::result::ResultExtension::display_err_or_some(
|
||||
rmc_conn.make_raw_call(&message).await
|
||||
).ok_or(crate::rmc::response::ErrorCode::Core_Exception)
|
||||
).ok_or(splatoon_server_rust::rmc::response::ErrorCode::Core_Exception)
|
||||
}.to_tokens(tokens);
|
||||
} else {
|
||||
quote!{
|
||||
crate::result::ResultExtension::display_err_or_some(
|
||||
splatoon_server_rust::result::ResultExtension::display_err_or_some(
|
||||
rmc_conn.make_raw_call_no_response(&message).await
|
||||
);
|
||||
}.to_tokens(tokens);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue