kacrab_protocol/generated/
consumer_group_heartbeat_response.rs1#![allow(
3 missing_docs,
4 clippy::all,
5 clippy::pedantic,
6 clippy::nursery,
7 clippy::arithmetic_side_effects,
8 reason = "Generated protocol modules mirror Kafka's schema shape and intentionally trade \
9 hand-written lint style for reproducible wire-code output."
10)]
11use bytes::{Bytes, BytesMut};
12
13use crate::*;
14
15#[derive(Debug, Clone, PartialEq)]
16pub struct ConsumerGroupHeartbeatResponseData {
17 pub throttle_time_ms: i32,
20 pub error_code: i16,
22 pub error_message: Option<KafkaString>,
24 pub member_id: Option<KafkaString>,
27 pub member_epoch: i32,
29 pub heartbeat_interval_ms: i32,
31 pub assignment: Option<Box<Assignment>>,
33 pub _unknown_tagged_fields: Vec<RawTaggedField>,
34}
35impl Default for ConsumerGroupHeartbeatResponseData {
36 fn default() -> Self {
37 Self {
38 throttle_time_ms: 0_i32,
39 error_code: 0_i16,
40 error_message: None,
41 member_id: None,
42 member_epoch: 0_i32,
43 heartbeat_interval_ms: 0_i32,
44 assignment: None,
45 _unknown_tagged_fields: Vec::new(),
46 }
47 }
48}
49impl ConsumerGroupHeartbeatResponseData {
50 pub fn with_throttle_time_ms(mut self, value: i32) -> Self {
51 self.throttle_time_ms = value;
52 self
53 }
54 pub fn with_error_code(mut self, value: i16) -> Self {
55 self.error_code = value;
56 self
57 }
58 pub fn with_error_message(mut self, value: Option<KafkaString>) -> Self {
59 self.error_message = value;
60 self
61 }
62 pub fn with_member_id(mut self, value: Option<KafkaString>) -> Self {
63 self.member_id = value;
64 self
65 }
66 pub fn with_member_epoch(mut self, value: i32) -> Self {
67 self.member_epoch = value;
68 self
69 }
70 pub fn with_heartbeat_interval_ms(mut self, value: i32) -> Self {
71 self.heartbeat_interval_ms = value;
72 self
73 }
74 pub fn with_assignment(mut self, value: Option<Box<Assignment>>) -> Self {
75 self.assignment = value;
76 self
77 }
78 pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
79 if version < 0 || version > 1 {
80 return Err(UnsupportedVersion::new(68, version).into());
81 }
82 let throttle_time_ms;
83 let error_code;
84 let error_message;
85 let member_id;
86 let member_epoch;
87 let heartbeat_interval_ms;
88 let assignment;
89 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
90 throttle_time_ms = read_i32(buf)?;
91 error_code = read_i16(buf)?;
92 error_message = read_compact_nullable_string(buf)?;
93 member_id = read_compact_nullable_string(buf)?;
94 member_epoch = read_i32(buf)?;
95 heartbeat_interval_ms = read_i32(buf)?;
96 assignment = {
97 let marker = read_i8(buf)?;
98 if marker < 0 {
99 None
100 } else {
101 Some(Box::new(Assignment::read(buf, version)?))
102 }
103 };
104 let tagged_fields = read_tagged_fields(buf)?;
105 for field in &tagged_fields {
106 match field.tag {
107 _ => {
108 _unknown_tagged_fields.push(field.clone());
109 },
110 }
111 }
112 Ok(Self {
113 throttle_time_ms,
114 error_code,
115 error_message,
116 member_id,
117 member_epoch,
118 heartbeat_interval_ms,
119 assignment,
120 _unknown_tagged_fields,
121 })
122 }
123 pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
124 if version < 0 || version > 1 {
125 return Err(UnsupportedVersion::new(68, version).into());
126 }
127 write_i32(buf, self.throttle_time_ms);
128 write_i16(buf, self.error_code);
129 write_compact_nullable_string(buf, self.error_message.as_ref())?;
130 write_compact_nullable_string(buf, self.member_id.as_ref())?;
131 write_i32(buf, self.member_epoch);
132 write_i32(buf, self.heartbeat_interval_ms);
133 match &self.assignment {
134 None => {
135 write_i8(buf, -1);
136 },
137 Some(v) => {
138 write_i8(buf, 1);
139 v.write(buf, version)?;
140 },
141 }
142 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
143 all_tags.sort_by_key(|f| f.tag);
144 write_tagged_fields(buf, &all_tags)?;
145 Ok(())
146 }
147 pub fn encoded_len(&self, version: i16) -> Result<usize> {
148 if version < 0 || version > 1 {
149 return Err(UnsupportedVersion::new(68, version).into());
150 }
151 let mut len: usize = 0;
152 len += 4;
153 len += 2;
154 len += compact_nullable_string_len(self.error_message.as_ref())?;
155 len += compact_nullable_string_len(self.member_id.as_ref())?;
156 len += 4;
157 len += 4;
158 match &self.assignment {
159 None => {
160 len += 1;
161 },
162 Some(v) => {
163 len += 1;
164 len += v.encoded_len(version)?;
165 },
166 }
167 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
168 all_tags.sort_by_key(|f| f.tag);
169 len += tagged_fields_len(&all_tags)?;
170 Ok(len)
171 }
172}
173#[derive(Debug, Clone, PartialEq)]
174pub struct Assignment {
175 pub topic_partitions: Vec<TopicPartitions>,
177 pub _unknown_tagged_fields: Vec<RawTaggedField>,
178}
179impl Default for Assignment {
180 fn default() -> Self {
181 Self {
182 topic_partitions: Vec::new(),
183 _unknown_tagged_fields: Vec::new(),
184 }
185 }
186}
187impl Assignment {
188 pub fn with_topic_partitions(mut self, value: Vec<TopicPartitions>) -> Self {
189 self.topic_partitions = value;
190 self
191 }
192 pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
193 let topic_partitions;
194 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
195 topic_partitions = {
196 let len = read_compact_array_length(buf)?;
197 let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
198 for _ in 0..len {
199 arr.push(TopicPartitions::read(buf, version)?);
200 }
201 arr
202 };
203 let tagged_fields = read_tagged_fields(buf)?;
204 for field in &tagged_fields {
205 match field.tag {
206 _ => {
207 _unknown_tagged_fields.push(field.clone());
208 },
209 }
210 }
211 Ok(Self {
212 topic_partitions,
213 _unknown_tagged_fields,
214 })
215 }
216 pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
217 write_compact_array_length(buf, self.topic_partitions.len() as i32);
218 for el in &self.topic_partitions {
219 el.write(buf, version)?;
220 }
221 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
222 all_tags.sort_by_key(|f| f.tag);
223 write_tagged_fields(buf, &all_tags)?;
224 Ok(())
225 }
226 pub fn encoded_len(&self, version: i16) -> Result<usize> {
227 let mut len: usize = 0;
228 len += compact_array_length_len(self.topic_partitions.len() as i32);
229 for el in &self.topic_partitions {
230 len += el.encoded_len(version)?;
231 }
232 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
233 all_tags.sort_by_key(|f| f.tag);
234 len += tagged_fields_len(&all_tags)?;
235 Ok(len)
236 }
237}
238#[derive(Debug, Clone, PartialEq)]
239pub struct TopicPartitions {
240 pub topic_id: KafkaUuid,
242 pub partitions: Vec<i32>,
244 pub _unknown_tagged_fields: Vec<RawTaggedField>,
245}
246impl Default for TopicPartitions {
247 fn default() -> Self {
248 Self {
249 topic_id: KafkaUuid::ZERO,
250 partitions: Vec::new(),
251 _unknown_tagged_fields: Vec::new(),
252 }
253 }
254}
255impl TopicPartitions {
256 pub fn with_topic_id(mut self, value: KafkaUuid) -> Self {
257 self.topic_id = value;
258 self
259 }
260 pub fn with_partitions(mut self, value: Vec<i32>) -> Self {
261 self.partitions = value;
262 self
263 }
264 pub fn read(buf: &mut Bytes, _version: i16) -> Result<Self> {
265 let topic_id;
266 let partitions;
267 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
268 topic_id = read_uuid(buf)?;
269 partitions = {
270 let len = read_compact_array_length(buf)?;
271 let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
272 for _ in 0..len {
273 arr.push(read_i32(buf)?);
274 }
275 arr
276 };
277 let tagged_fields = read_tagged_fields(buf)?;
278 for field in &tagged_fields {
279 match field.tag {
280 _ => {
281 _unknown_tagged_fields.push(field.clone());
282 },
283 }
284 }
285 Ok(Self {
286 topic_id,
287 partitions,
288 _unknown_tagged_fields,
289 })
290 }
291 pub fn write(&self, buf: &mut BytesMut, _version: i16) -> Result<()> {
292 write_uuid(buf, &self.topic_id);
293 write_compact_array_length(buf, self.partitions.len() as i32);
294 for el in &self.partitions {
295 write_i32(buf, *el);
296 }
297 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
298 all_tags.sort_by_key(|f| f.tag);
299 write_tagged_fields(buf, &all_tags)?;
300 Ok(())
301 }
302 pub fn encoded_len(&self, _version: i16) -> Result<usize> {
303 let mut len: usize = 0;
304 len += 16;
305 len += compact_array_length_len(self.partitions.len() as i32);
306 len += self.partitions.len() * 4usize;
307 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
308 all_tags.sort_by_key(|f| f.tag);
309 len += tagged_fields_len(&all_tags)?;
310 Ok(len)
311 }
312}