refactor
This commit is contained in:
parent
a4ccc96ed0
commit
aab4414904
71 changed files with 293 additions and 4316 deletions
|
|
@ -65,7 +65,7 @@ fn gen_serialize_data_struct(
|
|||
let ident = f.ident.as_ref().unwrap();
|
||||
|
||||
serialize_content.append_all(quote! {
|
||||
self.#ident.serialize(writer)?;
|
||||
rnex_core::rmc::structures::RmcSerialize::serialize(&self.#ident, writer)?;
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -143,7 +143,7 @@ fn gen_serialize_data_struct(
|
|||
|
||||
quote! {
|
||||
#pre_inner
|
||||
rust_nex::rmc::structures::rmc_struct::write_struct(writer, #version, |mut writer|{
|
||||
rnex_core::rmc::structures::rmc_struct::write_struct(writer, #version, |mut writer|{
|
||||
#serialize_base_content
|
||||
})?;
|
||||
|
||||
|
|
@ -176,7 +176,7 @@ fn gen_serialize_data_struct(
|
|||
|
||||
quote! {
|
||||
#pre_inner
|
||||
Ok(rust_nex::rmc::structures::rmc_struct::read_struct(reader, #version, move |mut reader|{
|
||||
Ok(rnex_core::rmc::structures::rmc_struct::read_struct(reader, #version, move |mut reader|{
|
||||
#deserialize_base_content
|
||||
})?)
|
||||
}
|
||||
|
|
@ -235,7 +235,7 @@ pub fn rmc_serialize(input: TokenStream) -> TokenStream {
|
|||
let name = &field.ident;
|
||||
|
||||
base.append_all(quote!{
|
||||
#name: <#ty as rust_nex::rmc::structures::RmcSerialize>::deserialize(reader)?,
|
||||
#name: <#ty as rnex_core::rmc::structures::RmcSerialize>::deserialize(reader)?,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -248,7 +248,7 @@ pub fn rmc_serialize(input: TokenStream) -> TokenStream {
|
|||
let ty = &field.ty;
|
||||
|
||||
base.append_all(quote!{
|
||||
<#ty as rust_nex::rmc::structures::RmcSerialize>::deserialize(reader)?,
|
||||
<#ty as rnex_core::rmc::structures::RmcSerialize>::deserialize(reader)?,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -260,7 +260,7 @@ pub fn rmc_serialize(input: TokenStream) -> TokenStream {
|
|||
};
|
||||
|
||||
let mut se_with_fields = quote! {
|
||||
<#ty as rust_nex::rmc::structures::RmcSerialize>::serialize(&#val, writer)?;
|
||||
<#ty as rnex_core::rmc::structures::RmcSerialize>::serialize(&#val, writer)?;
|
||||
};
|
||||
|
||||
match &variant.fields {
|
||||
|
|
@ -270,7 +270,7 @@ pub fn rmc_serialize(input: TokenStream) -> TokenStream {
|
|||
let name = &field.ident;
|
||||
|
||||
se_with_fields.append_all(quote!{
|
||||
<#ty as rust_nex::rmc::structures::RmcSerialize>::serialize(#name ,writer)?;
|
||||
<#ty as rnex_core::rmc::structures::RmcSerialize>::serialize(#name ,writer)?;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -281,7 +281,7 @@ pub fn rmc_serialize(input: TokenStream) -> TokenStream {
|
|||
let ident = Ident::new(&format!("val_{}", i), Span::call_site());
|
||||
|
||||
se_with_fields.append_all(quote!{
|
||||
<#ty as rust_nex::rmc::structures::RmcSerialize>::serialize(#ident, writer)?;
|
||||
<#ty as rnex_core::rmc::structures::RmcSerialize>::serialize(#ident, writer)?;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -344,9 +344,9 @@ pub fn rmc_serialize(input: TokenStream) -> TokenStream {
|
|||
};
|
||||
|
||||
let deserialize_base_content = quote! {
|
||||
let val: Self = match <#ty as rust_nex::rmc::structures::RmcSerialize>::deserialize(reader)?{
|
||||
let val: Self = match <#ty as rnex_core::rmc::structures::RmcSerialize>::deserialize(reader)?{
|
||||
#inner_match_de
|
||||
v => return Err(rust_nex::rmc::structures::Error::UnexpectedValue(v as _))
|
||||
v => return Err(rnex_core::rmc::structures::Error::UnexpectedValue(v as _))
|
||||
};
|
||||
|
||||
Ok(val)
|
||||
|
|
@ -364,14 +364,14 @@ pub fn rmc_serialize(input: TokenStream) -> TokenStream {
|
|||
let ident = derive_input.ident;
|
||||
|
||||
let tokens = quote! {
|
||||
impl rust_nex::rmc::structures::RmcSerialize for #ident{
|
||||
fn serialize(&self, writer: &mut dyn ::std::io::Write) -> rust_nex::rmc::structures::Result<()>{
|
||||
impl rnex_core::rmc::structures::RmcSerialize for #ident{
|
||||
fn serialize(&self, writer: &mut dyn ::std::io::Write) -> rnex_core::rmc::structures::Result<()>{
|
||||
#serialize_base_content
|
||||
|
||||
|
||||
}
|
||||
|
||||
fn deserialize(reader: &mut dyn ::std::io::Read) -> rust_nex::rmc::structures::Result<Self>{
|
||||
fn deserialize(reader: &mut dyn ::std::io::Read) -> rnex_core::rmc::structures::Result<Self>{
|
||||
#deserialize_base_content
|
||||
}
|
||||
}
|
||||
|
|
@ -511,8 +511,8 @@ pub fn rmc_struct(attr: TokenStream, input: TokenStream) -> TokenStream {
|
|||
|
||||
}
|
||||
|
||||
impl rust_nex::rmc::protocols::RmcCallable for #struct_name{
|
||||
async fn rmc_call(&self, remote_response_connection: &rust_nex::util::SendingBufferConnection, protocol_id: u16, method_id: u32, call_id: u32, rest: Vec<u8>){
|
||||
impl rnex_core::rmc::protocols::RmcCallable for #struct_name{
|
||||
async fn rmc_call(&self, remote_response_connection: &rnex_core::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 rust_nex::rmc::structures::RmcSerialize>::deserialize(
|
||||
<#param_type as rnex_core::rmc::structures::RmcSerialize>::deserialize(
|
||||
&mut cursor
|
||||
) else
|
||||
}.to_tokens(tokens);
|
||||
|
|
@ -84,7 +84,7 @@ impl RmcProtocolData{
|
|||
quote! {
|
||||
{
|
||||
log::error!(#error_msg);
|
||||
return Err(rust_nex::rmc::response::ErrorCode::Core_InvalidArgument);
|
||||
return Err(rnex_core::rmc::response::ErrorCode::Core_InvalidArgument);
|
||||
};
|
||||
}.to_tokens(tokens)
|
||||
} else {
|
||||
|
|
@ -116,7 +116,7 @@ impl RmcProtocolData{
|
|||
quote!{
|
||||
let retval = retval?;
|
||||
let mut vec = Vec::new();
|
||||
rust_nex::rmc::structures::RmcSerialize::serialize(&retval, &mut vec).ok();
|
||||
rnex_core::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: &rust_nex::util::SendingBufferConnection,
|
||||
remote_response_connection: &rnex_core::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(rust_nex::rmc::response::ErrorCode::Core_NotImplemented)
|
||||
Err(rnex_core::rmc::response::ErrorCode::Core_NotImplemented)
|
||||
}.to_tokens(tokens);
|
||||
}
|
||||
});
|
||||
|
|
@ -176,7 +176,7 @@ impl RmcProtocolData{
|
|||
|
||||
if *has_returns{
|
||||
quote!{
|
||||
rust_nex::rmc::response::send_result(
|
||||
rnex_core::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: rust_nex::rmc::protocols::HasRmcConnection
|
||||
pub trait #remote_name: rnex_core::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!{
|
||||
rust_nex::result::ResultExtension::display_err_or_some(
|
||||
<#param_type as rust_nex::rmc::structures::RmcSerialize>::serialize(
|
||||
rnex_core::result::ResultExtension::display_err_or_some(
|
||||
<#param_type as rnex_core::rmc::structures::RmcSerialize>::serialize(
|
||||
&#param_name,
|
||||
&mut cursor
|
||||
)
|
||||
).ok_or(rust_nex::rmc::response::ErrorCode::Core_InvalidArgument)
|
||||
).ok_or(rnex_core::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 = rust_nex::rmc::message::RMCMessage{
|
||||
let message = rnex_core::rmc::message::RMCMessage{
|
||||
call_id,
|
||||
method_id: #method_id,
|
||||
protocol_id: #proto_id,
|
||||
rest_of_data: send_data
|
||||
};
|
||||
|
||||
let rmc_conn = <Self as rust_nex::rmc::protocols::HasRmcConnection>::get_connection(self);
|
||||
let rmc_conn = <Self as rnex_core::rmc::protocols::HasRmcConnection>::get_connection(self);
|
||||
}.to_tokens(tokens);
|
||||
|
||||
if *has_returns{
|
||||
quote!{
|
||||
rust_nex::result::ResultExtension::display_err_or_some(
|
||||
rnex_core::result::ResultExtension::display_err_or_some(
|
||||
rmc_conn.make_raw_call(&message).await
|
||||
).ok_or(rust_nex::rmc::response::ErrorCode::Core_Exception)
|
||||
).ok_or(rnex_core::rmc::response::ErrorCode::Core_Exception)
|
||||
}.to_tokens(tokens);
|
||||
} else {
|
||||
quote!{
|
||||
rust_nex::result::ResultExtension::display_err_or_some(
|
||||
rnex_core::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