Skip to content

Commit bca313a

Browse files
[ISSUE mxsm#2932]♻️Refactor WipeWritePermOfBrokerResponseHeader with derive marco RequestHeaderCodec (mxsm#3214)
1 parent 4fb4259 commit bca313a

File tree

1 file changed

+1
-29
lines changed

1 file changed

+1
-29
lines changed

rocketmq-remoting/src/protocol/header/namesrv/perm_broker_header.rs

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -39,46 +39,18 @@ impl WipeWritePermOfBrokerRequestHeader {
3939
}
4040
}
4141

42-
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
42+
#[derive(Debug, Clone, Deserialize, Serialize, Default, RequestHeaderCodec)]
4343
#[serde(rename_all = "camelCase")]
4444
pub struct WipeWritePermOfBrokerResponseHeader {
4545
pub wipe_topic_count: i32,
4646
}
4747

4848
impl WipeWritePermOfBrokerResponseHeader {
49-
const WIPE_TOPIC_COUNT: &'static str = "wipeTopicCount";
50-
5149
pub fn new(wipe_topic_count: i32) -> Self {
5250
Self { wipe_topic_count }
5351
}
5452
}
5553

56-
impl CommandCustomHeader for WipeWritePermOfBrokerResponseHeader {
57-
fn to_map(&self) -> Option<HashMap<CheetahString, CheetahString>> {
58-
Some(HashMap::from([(
59-
CheetahString::from_static_str(Self::WIPE_TOPIC_COUNT),
60-
CheetahString::from_string(self.wipe_topic_count.to_string()),
61-
)]))
62-
}
63-
}
64-
65-
impl FromMap for WipeWritePermOfBrokerResponseHeader {
66-
type Error = rocketmq_error::RocketmqError;
67-
68-
type Target = Self;
69-
70-
fn from(map: &HashMap<CheetahString, CheetahString>) -> Result<Self::Target, Self::Error> {
71-
Ok(WipeWritePermOfBrokerResponseHeader {
72-
wipe_topic_count: map
73-
.get(&CheetahString::from_static_str(
74-
WipeWritePermOfBrokerResponseHeader::WIPE_TOPIC_COUNT,
75-
))
76-
.and_then(|s| s.parse::<i32>().ok())
77-
.unwrap_or(0),
78-
})
79-
}
80-
}
81-
8254
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
8355
#[serde(rename_all = "camelCase")]
8456
pub struct AddWritePermOfBrokerRequestHeader {

0 commit comments

Comments
 (0)