rocketmq_remoting/protocol/header/namesrv/
perm_broker_header.rs

1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18use cheetah_string::CheetahString;
19use rocketmq_macros::RequestHeaderCodecV2;
20use serde::Deserialize;
21use serde::Serialize;
22
23#[derive(Debug, Clone, Deserialize, Serialize, Default, RequestHeaderCodecV2)]
24#[serde(rename_all = "camelCase")]
25pub struct WipeWritePermOfBrokerRequestHeader {
26    #[required]
27    pub broker_name: CheetahString,
28}
29
30impl WipeWritePermOfBrokerRequestHeader {
31    pub fn new(broker_name: impl Into<CheetahString>) -> Self {
32        Self {
33            broker_name: broker_name.into(),
34        }
35    }
36}
37
38#[derive(Debug, Clone, Deserialize, Serialize, Default, RequestHeaderCodecV2)]
39#[serde(rename_all = "camelCase")]
40pub struct WipeWritePermOfBrokerResponseHeader {
41    pub wipe_topic_count: i32,
42}
43
44impl WipeWritePermOfBrokerResponseHeader {
45    pub fn new(wipe_topic_count: i32) -> Self {
46        Self { wipe_topic_count }
47    }
48
49    pub fn get_wipe_topic_count(&self) -> i32 {
50        self.wipe_topic_count
51    }
52}
53
54#[derive(Debug, Clone, Deserialize, Serialize, Default, RequestHeaderCodecV2)]
55#[serde(rename_all = "camelCase")]
56pub struct AddWritePermOfBrokerRequestHeader {
57    pub broker_name: CheetahString,
58}
59
60impl AddWritePermOfBrokerRequestHeader {
61    pub fn new(broker_name: impl Into<CheetahString>) -> Self {
62        Self {
63            broker_name: broker_name.into(),
64        }
65    }
66}
67
68#[derive(Debug, Clone, Deserialize, Serialize, Default, RequestHeaderCodecV2)]
69#[serde(rename_all = "camelCase")]
70pub struct AddWritePermOfBrokerResponseHeader {
71    pub add_topic_count: i32,
72}
73
74impl AddWritePermOfBrokerResponseHeader {
75    //const ADD_TOPIC_COUNT: &'static str = "addTopicCount";
76
77    pub fn new(add_topic_count: i32) -> Self {
78        Self { add_topic_count }
79    }
80}
81
82impl AddWritePermOfBrokerResponseHeader {
83    pub fn get_add_topic_count(&self) -> i32 {
84        self.add_topic_count
85    }
86}
87
88// impl CommandCustomHeader for AddWritePermOfBrokerResponseHeader {
89//     fn to_map(&self) -> Option<HashMap<CheetahString, CheetahString>> {
90//         Some(HashMap::from([(
91//             CheetahString::from_static_str(Self::ADD_TOPIC_COUNT),
92//             CheetahString::from_string(self.add_topic_count.to_string()),
93//         )]))
94//     }
95// }
96
97// impl FromMap for AddWritePermOfBrokerResponseHeader {
98//     type Error = rocketmq_error::RocketmqError;
99
100//     type Target = Self;
101
102//     fn from(map: &HashMap<CheetahString, CheetahString>) -> Result<Self::Target, Self::Error> {
103//         Ok(AddWritePermOfBrokerResponseHeader {
104//             add_topic_count: map
105//                 .get(&CheetahString::from_static_str(
106//                     AddWritePermOfBrokerResponseHeader::ADD_TOPIC_COUNT,
107//                 ))
108//                 .and_then(|s| s.parse::<i32>().ok())
109//                 .unwrap_or(0),
110//         })
111//     }
112// }