rocketmq_remoting/protocol/body/
topic_info_wrapper.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 std::collections::HashMap;
19
20use cheetah_string::CheetahString;
21use rocketmq_common::common::config::TopicConfig;
22use serde::Deserialize;
23use serde::Serialize;
24
25use crate::protocol::DataVersion;
26
27pub mod topic_config_wrapper;
28pub mod topic_queue_wrapper;
29
30#[derive(Debug, Deserialize, Serialize, Default)]
31pub struct TopicConfigSerializeWrapper {
32    #[serde(rename = "topicConfigTable")]
33    topic_config_table: Option<HashMap<CheetahString, TopicConfig>>,
34
35    #[serde(rename = "dataVersion")]
36    data_version: Option<DataVersion>,
37}
38
39impl TopicConfigSerializeWrapper {
40    pub fn new(
41        topic_config_table: Option<HashMap<CheetahString, TopicConfig>>,
42        data_version: Option<DataVersion>,
43    ) -> Self {
44        Self {
45            topic_config_table,
46            data_version,
47        }
48    }
49}
50
51impl TopicConfigSerializeWrapper {
52    pub fn topic_config_table(&self) -> Option<&HashMap<CheetahString, TopicConfig>> {
53        match &self.topic_config_table {
54            None => None,
55            Some(value) => Some(value),
56        }
57    }
58
59    pub fn data_version(&self) -> Option<&DataVersion> {
60        match &self.data_version {
61            None => None,
62            Some(value) => Some(value),
63        }
64    }
65
66    pub fn set_topic_config_table(
67        &mut self,
68        topic_config_table: Option<HashMap<CheetahString, TopicConfig>>,
69    ) {
70        self.topic_config_table = topic_config_table;
71    }
72
73    pub fn set_data_version(&mut self, data_version: Option<DataVersion>) {
74        self.data_version = data_version;
75    }
76
77    pub fn take_topic_config_table(&mut self) -> Option<HashMap<CheetahString, TopicConfig>> {
78        self.topic_config_table.take()
79    }
80}