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