Skip to content

[ISSUE #1476]♻️Refactor derive RequestHeaderCodec parse logic🔥 #1478

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions rocketmq-macros/src/request_header_custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,17 @@ pub(super) fn request_header_codec_inner(
&format!("{}", field_name).to_ascii_uppercase(),
field_name.span(),
);
let type_name = if let Some(value) = &has_option {
get_type_name(*value)
} else {
get_type_name(&field.ty)
};
(
quote! {
const #static_name: &'static str = #camel_case_name;
},
(
if let Some(value) = has_option {
let type_name = get_type_name(value);
if let Some(_) = has_option {
if type_name == "CheetahString" {
quote! {
if let Some(ref value) = self.#field_name {
Expand All @@ -92,7 +96,7 @@ pub(super) fn request_header_codec_inner(
}
} else {
quote! {
if let Some(value) = self.#field_name {
if let Some(ref value) = self.#field_name {
map.insert (
cheetah_string::CheetahString::from_static_str(Self::#static_name),
cheetah_string::CheetahString::from_string(value.to_string())
Expand All @@ -101,7 +105,6 @@ pub(super) fn request_header_codec_inner(
}
}
} else {
let type_name = get_type_name(&field.ty);
if type_name == "CheetahString" {
quote! {
map.insert (
Expand All @@ -127,7 +130,6 @@ pub(super) fn request_header_codec_inner(
},
// build FromMap impl
if let Some(value) = has_option {
let type_name = get_type_name(value);
if type_name == "CheetahString" || type_name == "String" {
if required {
quote! {
Expand Down Expand Up @@ -161,7 +163,6 @@ pub(super) fn request_header_codec_inner(
}
} else {
let types = &field.ty;
let type_name = get_type_name(types);
if type_name == "CheetahString" || type_name == "String" {
if required {
quote! {
Expand Down
Loading