rocketmq_remoting/protocol/header/
query_consumer_offset_request_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
23use crate::protocol::header::message_operation_header::TopicRequestHeaderTrait;
24use crate::protocol::header::namesrv::topic_operation_header::TopicRequestHeader;
25
26#[derive(Debug, Clone, Serialize, Deserialize, RequestHeaderCodecV2)]
27#[serde(rename_all = "camelCase")]
28pub struct QueryConsumerOffsetRequestHeader {
29    pub consumer_group: CheetahString,
30    pub topic: CheetahString,
31    pub queue_id: i32,
32
33    pub set_zero_if_not_found: Option<bool>,
34    #[serde(flatten)]
35    pub topic_request_header: Option<TopicRequestHeader>,
36}
37
38impl TopicRequestHeaderTrait for QueryConsumerOffsetRequestHeader {
39    fn set_lo(&mut self, lo: Option<bool>) {
40        self.topic_request_header.as_mut().unwrap().lo = lo;
41    }
42
43    fn lo(&self) -> Option<bool> {
44        self.topic_request_header.as_ref().unwrap().lo
45    }
46
47    fn set_topic(&mut self, topic: CheetahString) {
48        self.topic = topic;
49    }
50
51    fn topic(&self) -> &CheetahString {
52        &self.topic
53    }
54
55    fn broker_name(&self) -> Option<&CheetahString> {
56        self.topic_request_header
57            .as_ref()
58            .unwrap()
59            .rpc
60            .as_ref()
61            .unwrap()
62            .broker_name
63            .as_ref()
64    }
65
66    fn set_broker_name(&mut self, broker_name: CheetahString) {
67        self.topic_request_header
68            .as_mut()
69            .unwrap()
70            .rpc
71            .as_mut()
72            .unwrap()
73            .broker_name = Some(broker_name);
74    }
75
76    fn namespace(&self) -> Option<&str> {
77        self.topic_request_header
78            .as_ref()
79            .unwrap()
80            .rpc
81            .as_ref()
82            .unwrap()
83            .namespace
84            .as_deref()
85    }
86
87    fn set_namespace(&mut self, namespace: CheetahString) {
88        self.topic_request_header
89            .as_mut()
90            .unwrap()
91            .rpc
92            .as_mut()
93            .unwrap()
94            .namespace = Some(namespace);
95    }
96
97    fn namespaced(&self) -> Option<bool> {
98        self.topic_request_header
99            .as_ref()
100            .unwrap()
101            .rpc
102            .as_ref()
103            .unwrap()
104            .namespaced
105    }
106
107    fn set_namespaced(&mut self, namespaced: bool) {
108        self.topic_request_header
109            .as_mut()
110            .unwrap()
111            .rpc
112            .as_mut()
113            .unwrap()
114            .namespaced = Some(namespaced);
115    }
116
117    fn oneway(&self) -> Option<bool> {
118        self.topic_request_header
119            .as_ref()
120            .unwrap()
121            .rpc
122            .as_ref()
123            .unwrap()
124            .oneway
125    }
126
127    fn set_oneway(&mut self, oneway: bool) {
128        self.topic_request_header
129            .as_mut()
130            .unwrap()
131            .rpc
132            .as_mut()
133            .unwrap()
134            .oneway = Some(oneway);
135    }
136
137    fn queue_id(&self) -> i32 {
138        self.queue_id
139    }
140
141    fn set_queue_id(&mut self, queue_id: i32) {
142        self.queue_id = queue_id;
143    }
144}