1#![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 ShareGroupDescribeResponseData {
17 pub throttle_time_ms: i32,
20 pub groups: Vec<DescribedGroup>,
22 pub _unknown_tagged_fields: Vec<RawTaggedField>,
23}
24impl Default for ShareGroupDescribeResponseData {
25 fn default() -> Self {
26 Self {
27 throttle_time_ms: 0_i32,
28 groups: Vec::new(),
29 _unknown_tagged_fields: Vec::new(),
30 }
31 }
32}
33impl ShareGroupDescribeResponseData {
34 pub fn with_throttle_time_ms(mut self, value: i32) -> Self {
35 self.throttle_time_ms = value;
36 self
37 }
38 pub fn with_groups(mut self, value: Vec<DescribedGroup>) -> Self {
39 self.groups = value;
40 self
41 }
42 pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
43 if version < 1 || version > 1 {
44 return Err(UnsupportedVersion::new(77, version).into());
45 }
46 let throttle_time_ms;
47 let groups;
48 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
49 throttle_time_ms = read_i32(buf)?;
50 groups = {
51 let len = read_compact_array_length(buf)?;
52 let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
53 for _ in 0..len {
54 arr.push(DescribedGroup::read(buf, version)?);
55 }
56 arr
57 };
58 let tagged_fields = read_tagged_fields(buf)?;
59 for field in &tagged_fields {
60 match field.tag {
61 _ => {
62 _unknown_tagged_fields.push(field.clone());
63 },
64 }
65 }
66 Ok(Self {
67 throttle_time_ms,
68 groups,
69 _unknown_tagged_fields,
70 })
71 }
72 pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
73 if version < 1 || version > 1 {
74 return Err(UnsupportedVersion::new(77, version).into());
75 }
76 write_i32(buf, self.throttle_time_ms);
77 write_compact_array_length(buf, self.groups.len() as i32);
78 for el in &self.groups {
79 el.write(buf, version)?;
80 }
81 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
82 all_tags.sort_by_key(|f| f.tag);
83 write_tagged_fields(buf, &all_tags)?;
84 Ok(())
85 }
86 pub fn encoded_len(&self, version: i16) -> Result<usize> {
87 if version < 1 || version > 1 {
88 return Err(UnsupportedVersion::new(77, version).into());
89 }
90 let mut len: usize = 0;
91 len += 4;
92 len += compact_array_length_len(self.groups.len() as i32);
93 for el in &self.groups {
94 len += el.encoded_len(version)?;
95 }
96 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
97 all_tags.sort_by_key(|f| f.tag);
98 len += tagged_fields_len(&all_tags)?;
99 Ok(len)
100 }
101}
102#[derive(Debug, Clone, PartialEq)]
103pub struct DescribedGroup {
104 pub error_code: i16,
106 pub error_message: Option<KafkaString>,
108 pub group_id: KafkaString,
110 pub group_state: KafkaString,
112 pub group_epoch: i32,
114 pub assignment_epoch: i32,
116 pub assignor_name: KafkaString,
118 pub members: Vec<Member>,
120 pub authorized_operations: i32,
122 pub _unknown_tagged_fields: Vec<RawTaggedField>,
123}
124impl Default for DescribedGroup {
125 fn default() -> Self {
126 Self {
127 error_code: 0_i16,
128 error_message: None,
129 group_id: KafkaString::default(),
130 group_state: KafkaString::default(),
131 group_epoch: 0_i32,
132 assignment_epoch: 0_i32,
133 assignor_name: KafkaString::default(),
134 members: Vec::new(),
135 authorized_operations: i32::MIN,
136 _unknown_tagged_fields: Vec::new(),
137 }
138 }
139}
140impl DescribedGroup {
141 pub fn with_error_code(mut self, value: i16) -> Self {
142 self.error_code = value;
143 self
144 }
145 pub fn with_error_message(mut self, value: Option<KafkaString>) -> Self {
146 self.error_message = value;
147 self
148 }
149 pub fn with_group_id(mut self, value: KafkaString) -> Self {
150 self.group_id = value;
151 self
152 }
153 pub fn with_group_state(mut self, value: KafkaString) -> Self {
154 self.group_state = value;
155 self
156 }
157 pub fn with_group_epoch(mut self, value: i32) -> Self {
158 self.group_epoch = value;
159 self
160 }
161 pub fn with_assignment_epoch(mut self, value: i32) -> Self {
162 self.assignment_epoch = value;
163 self
164 }
165 pub fn with_assignor_name(mut self, value: KafkaString) -> Self {
166 self.assignor_name = value;
167 self
168 }
169 pub fn with_members(mut self, value: Vec<Member>) -> Self {
170 self.members = value;
171 self
172 }
173 pub fn with_authorized_operations(mut self, value: i32) -> Self {
174 self.authorized_operations = value;
175 self
176 }
177 pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
178 let error_code;
179 let error_message;
180 let group_id;
181 let group_state;
182 let group_epoch;
183 let assignment_epoch;
184 let assignor_name;
185 let members;
186 let authorized_operations;
187 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
188 error_code = read_i16(buf)?;
189 error_message = read_compact_nullable_string(buf)?;
190 group_id = read_compact_string(buf)?;
191 group_state = read_compact_string(buf)?;
192 group_epoch = read_i32(buf)?;
193 assignment_epoch = read_i32(buf)?;
194 assignor_name = read_compact_string(buf)?;
195 members = {
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(Member::read(buf, version)?);
200 }
201 arr
202 };
203 authorized_operations = read_i32(buf)?;
204 let tagged_fields = read_tagged_fields(buf)?;
205 for field in &tagged_fields {
206 match field.tag {
207 _ => {
208 _unknown_tagged_fields.push(field.clone());
209 },
210 }
211 }
212 Ok(Self {
213 error_code,
214 error_message,
215 group_id,
216 group_state,
217 group_epoch,
218 assignment_epoch,
219 assignor_name,
220 members,
221 authorized_operations,
222 _unknown_tagged_fields,
223 })
224 }
225 pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
226 write_i16(buf, self.error_code);
227 write_compact_nullable_string(buf, self.error_message.as_ref())?;
228 write_compact_string(buf, &self.group_id)?;
229 write_compact_string(buf, &self.group_state)?;
230 write_i32(buf, self.group_epoch);
231 write_i32(buf, self.assignment_epoch);
232 write_compact_string(buf, &self.assignor_name)?;
233 write_compact_array_length(buf, self.members.len() as i32);
234 for el in &self.members {
235 el.write(buf, version)?;
236 }
237 write_i32(buf, self.authorized_operations);
238 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
239 all_tags.sort_by_key(|f| f.tag);
240 write_tagged_fields(buf, &all_tags)?;
241 Ok(())
242 }
243 pub fn encoded_len(&self, version: i16) -> Result<usize> {
244 let mut len: usize = 0;
245 len += 2;
246 len += compact_nullable_string_len(self.error_message.as_ref())?;
247 len += compact_string_len(&self.group_id)?;
248 len += compact_string_len(&self.group_state)?;
249 len += 4;
250 len += 4;
251 len += compact_string_len(&self.assignor_name)?;
252 len += compact_array_length_len(self.members.len() as i32);
253 for el in &self.members {
254 len += el.encoded_len(version)?;
255 }
256 len += 4;
257 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
258 all_tags.sort_by_key(|f| f.tag);
259 len += tagged_fields_len(&all_tags)?;
260 Ok(len)
261 }
262}
263#[derive(Debug, Clone, PartialEq)]
264pub struct Member {
265 pub member_id: KafkaString,
267 pub rack_id: Option<KafkaString>,
269 pub member_epoch: i32,
271 pub client_id: KafkaString,
273 pub client_host: KafkaString,
275 pub subscribed_topic_names: Vec<KafkaString>,
277 pub assignment: Assignment,
279 pub _unknown_tagged_fields: Vec<RawTaggedField>,
280}
281impl Default for Member {
282 fn default() -> Self {
283 Self {
284 member_id: KafkaString::default(),
285 rack_id: None,
286 member_epoch: 0_i32,
287 client_id: KafkaString::default(),
288 client_host: KafkaString::default(),
289 subscribed_topic_names: Vec::new(),
290 assignment: Assignment::default(),
291 _unknown_tagged_fields: Vec::new(),
292 }
293 }
294}
295impl Member {
296 pub fn with_member_id(mut self, value: KafkaString) -> Self {
297 self.member_id = value;
298 self
299 }
300 pub fn with_rack_id(mut self, value: Option<KafkaString>) -> Self {
301 self.rack_id = value;
302 self
303 }
304 pub fn with_member_epoch(mut self, value: i32) -> Self {
305 self.member_epoch = value;
306 self
307 }
308 pub fn with_client_id(mut self, value: KafkaString) -> Self {
309 self.client_id = value;
310 self
311 }
312 pub fn with_client_host(mut self, value: KafkaString) -> Self {
313 self.client_host = value;
314 self
315 }
316 pub fn with_subscribed_topic_names(mut self, value: Vec<KafkaString>) -> Self {
317 self.subscribed_topic_names = value;
318 self
319 }
320 pub fn with_assignment(mut self, value: Assignment) -> Self {
321 self.assignment = value;
322 self
323 }
324 pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
325 let member_id;
326 let rack_id;
327 let member_epoch;
328 let client_id;
329 let client_host;
330 let subscribed_topic_names;
331 let assignment;
332 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
333 member_id = read_compact_string(buf)?;
334 rack_id = read_compact_nullable_string(buf)?;
335 member_epoch = read_i32(buf)?;
336 client_id = read_compact_string(buf)?;
337 client_host = read_compact_string(buf)?;
338 subscribed_topic_names = {
339 let len = read_compact_array_length(buf)?;
340 let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
341 for _ in 0..len {
342 arr.push(read_compact_string(buf)?);
343 }
344 arr
345 };
346 assignment = Assignment::read(buf, version)?;
347 let tagged_fields = read_tagged_fields(buf)?;
348 for field in &tagged_fields {
349 match field.tag {
350 _ => {
351 _unknown_tagged_fields.push(field.clone());
352 },
353 }
354 }
355 Ok(Self {
356 member_id,
357 rack_id,
358 member_epoch,
359 client_id,
360 client_host,
361 subscribed_topic_names,
362 assignment,
363 _unknown_tagged_fields,
364 })
365 }
366 pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
367 write_compact_string(buf, &self.member_id)?;
368 write_compact_nullable_string(buf, self.rack_id.as_ref())?;
369 write_i32(buf, self.member_epoch);
370 write_compact_string(buf, &self.client_id)?;
371 write_compact_string(buf, &self.client_host)?;
372 write_compact_array_length(buf, self.subscribed_topic_names.len() as i32);
373 for el in &self.subscribed_topic_names {
374 write_compact_string(buf, el)?;
375 }
376 self.assignment.write(buf, version)?;
377 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
378 all_tags.sort_by_key(|f| f.tag);
379 write_tagged_fields(buf, &all_tags)?;
380 Ok(())
381 }
382 pub fn encoded_len(&self, version: i16) -> Result<usize> {
383 let mut len: usize = 0;
384 len += compact_string_len(&self.member_id)?;
385 len += compact_nullable_string_len(self.rack_id.as_ref())?;
386 len += 4;
387 len += compact_string_len(&self.client_id)?;
388 len += compact_string_len(&self.client_host)?;
389 len += compact_array_length_len(self.subscribed_topic_names.len() as i32);
390 for el in &self.subscribed_topic_names {
391 len += compact_string_len(el)?;
392 }
393 len += self.assignment.encoded_len(version)?;
394 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
395 all_tags.sort_by_key(|f| f.tag);
396 len += tagged_fields_len(&all_tags)?;
397 Ok(len)
398 }
399}
400#[derive(Debug, Clone, PartialEq)]
401pub struct TopicPartitions {
402 pub topic_id: KafkaUuid,
404 pub topic_name: KafkaString,
406 pub partitions: Vec<i32>,
408 pub _unknown_tagged_fields: Vec<RawTaggedField>,
409}
410impl Default for TopicPartitions {
411 fn default() -> Self {
412 Self {
413 topic_id: KafkaUuid::ZERO,
414 topic_name: KafkaString::default(),
415 partitions: Vec::new(),
416 _unknown_tagged_fields: Vec::new(),
417 }
418 }
419}
420impl TopicPartitions {
421 pub fn with_topic_id(mut self, value: KafkaUuid) -> Self {
422 self.topic_id = value;
423 self
424 }
425 pub fn with_topic_name(mut self, value: KafkaString) -> Self {
426 self.topic_name = value;
427 self
428 }
429 pub fn with_partitions(mut self, value: Vec<i32>) -> Self {
430 self.partitions = value;
431 self
432 }
433 pub fn read(buf: &mut Bytes, _version: i16) -> Result<Self> {
434 let topic_id;
435 let topic_name;
436 let partitions;
437 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
438 topic_id = read_uuid(buf)?;
439 topic_name = read_compact_string(buf)?;
440 partitions = {
441 let len = read_compact_array_length(buf)?;
442 let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
443 for _ in 0..len {
444 arr.push(read_i32(buf)?);
445 }
446 arr
447 };
448 let tagged_fields = read_tagged_fields(buf)?;
449 for field in &tagged_fields {
450 match field.tag {
451 _ => {
452 _unknown_tagged_fields.push(field.clone());
453 },
454 }
455 }
456 Ok(Self {
457 topic_id,
458 topic_name,
459 partitions,
460 _unknown_tagged_fields,
461 })
462 }
463 pub fn write(&self, buf: &mut BytesMut, _version: i16) -> Result<()> {
464 write_uuid(buf, &self.topic_id);
465 write_compact_string(buf, &self.topic_name)?;
466 write_compact_array_length(buf, self.partitions.len() as i32);
467 for el in &self.partitions {
468 write_i32(buf, *el);
469 }
470 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
471 all_tags.sort_by_key(|f| f.tag);
472 write_tagged_fields(buf, &all_tags)?;
473 Ok(())
474 }
475 pub fn encoded_len(&self, _version: i16) -> Result<usize> {
476 let mut len: usize = 0;
477 len += 16;
478 len += compact_string_len(&self.topic_name)?;
479 len += compact_array_length_len(self.partitions.len() as i32);
480 len += self.partitions.len() * 4usize;
481 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
482 all_tags.sort_by_key(|f| f.tag);
483 len += tagged_fields_len(&all_tags)?;
484 Ok(len)
485 }
486}
487#[derive(Debug, Clone, PartialEq)]
488pub struct Assignment {
489 pub topic_partitions: Vec<TopicPartitions>,
491 pub _unknown_tagged_fields: Vec<RawTaggedField>,
492}
493impl Default for Assignment {
494 fn default() -> Self {
495 Self {
496 topic_partitions: Vec::new(),
497 _unknown_tagged_fields: Vec::new(),
498 }
499 }
500}
501impl Assignment {
502 pub fn with_topic_partitions(mut self, value: Vec<TopicPartitions>) -> Self {
503 self.topic_partitions = value;
504 self
505 }
506 pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
507 let topic_partitions;
508 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
509 topic_partitions = {
510 let len = read_compact_array_length(buf)?;
511 let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
512 for _ in 0..len {
513 arr.push(TopicPartitions::read(buf, version)?);
514 }
515 arr
516 };
517 let tagged_fields = read_tagged_fields(buf)?;
518 for field in &tagged_fields {
519 match field.tag {
520 _ => {
521 _unknown_tagged_fields.push(field.clone());
522 },
523 }
524 }
525 Ok(Self {
526 topic_partitions,
527 _unknown_tagged_fields,
528 })
529 }
530 pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
531 write_compact_array_length(buf, self.topic_partitions.len() as i32);
532 for el in &self.topic_partitions {
533 el.write(buf, version)?;
534 }
535 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
536 all_tags.sort_by_key(|f| f.tag);
537 write_tagged_fields(buf, &all_tags)?;
538 Ok(())
539 }
540 pub fn encoded_len(&self, version: i16) -> Result<usize> {
541 let mut len: usize = 0;
542 len += compact_array_length_len(self.topic_partitions.len() as i32);
543 for el in &self.topic_partitions {
544 len += el.encoded_len(version)?;
545 }
546 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
547 all_tags.sort_by_key(|f| f.tag);
548 len += tagged_fields_len(&all_tags)?;
549 Ok(len)
550 }
551}