rocketmq_remoting/protocol/body/
topic_info_wrapper.rs1use 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}