Skip to main content

krabka_protocol/opt/rustwide/workdir/generated/
ConsumerGroupDescribeResponse.owned.rs

1// AUTO-GENERATED by krabka-protocol-codegen against a9ce3221537b8653448750697915607dc7936cf3. Do not edit.
2
3use bytes::{Buf, BufMut};
4
5use crate::{
6    Decode, Encode, ProtocolError, UnknownTaggedFields,
7    primitives::{
8        array::{array_len_prefix_len, get_array_len, put_array_len},
9        fixed::{get_i8, get_i16, get_i32, put_i8, put_i16, put_i32},
10        string_bytes::{
11            compact_nullable_string_len, compact_string_len, get_compact_nullable_string_owned,
12            get_compact_string_owned, get_nullable_string_owned, get_string_owned,
13            nullable_string_len, put_compact_nullable_string, put_compact_string,
14            put_nullable_string, put_string, string_len,
15        },
16    },
17    tagged_fields::{WriteTaggedFields, read_tagged_fields, tagged_fields_len},
18};
19pub const API_KEY: i16 = 69;
20pub const MIN_VERSION: i16 = 0;
21pub const MAX_VERSION: i16 = 1;
22pub const FLEXIBLE_MIN: i16 = 0;
23#[inline]
24#[must_use]
25pub fn is_flexible(version: i16) -> bool {
26    version >= FLEXIBLE_MIN
27}
28#[derive(Debug, Clone, PartialEq, Eq, Default)]
29pub struct ConsumerGroupDescribeResponse {
30    pub throttle_time_ms: i32,
31    pub groups: Vec<DescribedGroup>,
32    pub unknown_tagged_fields: UnknownTaggedFields,
33}
34impl Encode for ConsumerGroupDescribeResponse {
35    fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
36        if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
37            return Err(ProtocolError::UnsupportedVersion {
38                api_key: API_KEY,
39                version,
40            });
41        }
42        let flex = is_flexible(version);
43        if version >= 0 {
44            put_i32(buf, self.throttle_time_ms);
45        }
46        if version >= 0 {
47            {
48                put_array_len(buf, (self.groups).len(), flex)?;
49                for it in &self.groups {
50                    it.encode(buf, version)?;
51                }
52            }
53        }
54        if flex {
55            let tagged = WriteTaggedFields::new();
56            tagged.write(buf, &self.unknown_tagged_fields)?;
57        }
58        Ok(())
59    }
60    fn encoded_len(&self, version: i16) -> usize {
61        let flex = is_flexible(version);
62        let mut n: usize = 0;
63        if version >= 0 {
64            n += 4;
65        }
66        if version >= 0 {
67            n += {
68                let prefix = array_len_prefix_len((self.groups).len(), flex);
69                let body: usize = (self.groups).iter().map(|it| it.encoded_len(version)).sum();
70                prefix + body
71            };
72        }
73        if flex {
74            let known_pairs: Vec<(u32, usize)> = Vec::new();
75            n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
76        }
77        n
78    }
79}
80impl Decode<'_> for ConsumerGroupDescribeResponse {
81    fn decode<B: Buf>(buf: &mut B, version: i16) -> Result<Self, ProtocolError> {
82        if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
83            return Err(ProtocolError::UnsupportedVersion {
84                api_key: API_KEY,
85                version,
86            });
87        }
88        let flex = is_flexible(version);
89        let mut out = Self::default();
90        if version >= 0 {
91            out.throttle_time_ms = get_i32(buf)?;
92        }
93        if version >= 0 {
94            out.groups = {
95                let n = get_array_len(buf, flex)?;
96                let mut v = Vec::with_capacity(n);
97                for _ in 0..n {
98                    v.push(DescribedGroup::decode(buf, version)?);
99                }
100                v
101            };
102        }
103        if flex {
104            out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
105        }
106        Ok(out)
107    }
108}
109#[cfg(test)]
110impl ConsumerGroupDescribeResponse {
111    #[must_use]
112    pub fn populated(version: i16) -> Self {
113        let mut m = Self::default();
114        if version >= 0 {
115            m.throttle_time_ms = 1i32;
116        }
117        if version >= 0 {
118            m.groups = vec![DescribedGroup::populated(version)];
119        }
120        m
121    }
122}
123#[derive(Debug, Clone, PartialEq, Eq)]
124pub struct DescribedGroup {
125    pub error_code: i16,
126    pub error_message: Option<String>,
127    pub group_id: String,
128    pub group_state: String,
129    pub group_epoch: i32,
130    pub assignment_epoch: i32,
131    pub assignor_name: String,
132    pub members: Vec<Member>,
133    pub authorized_operations: i32,
134    pub unknown_tagged_fields: UnknownTaggedFields,
135}
136impl Default for DescribedGroup {
137    fn default() -> Self {
138        Self {
139            error_code: 0i16,
140            error_message: None,
141            group_id: String::new(),
142            group_state: String::new(),
143            group_epoch: 0i32,
144            assignment_epoch: 0i32,
145            assignor_name: String::new(),
146            members: Vec::new(),
147            authorized_operations: -2_147_483_648i32,
148            unknown_tagged_fields: UnknownTaggedFields::default(),
149        }
150    }
151}
152impl DescribedGroup {
153    fn encode_field_0<B: BufMut>(&self, buf: &mut B, version: i16, _flex: bool) {
154        if version >= 0 {
155            put_i16(buf, self.error_code);
156        }
157    }
158    fn encode_field_1<B: BufMut>(
159        &self,
160        buf: &mut B,
161        version: i16,
162        flex: bool,
163    ) -> Result<(), ProtocolError> {
164        if version >= 0 {
165            if flex {
166                put_compact_nullable_string(buf, self.error_message.as_deref())?;
167            } else {
168                put_nullable_string(buf, self.error_message.as_deref())?;
169            }
170        }
171        Ok(())
172    }
173    fn encode_field_2<B: BufMut>(
174        &self,
175        buf: &mut B,
176        version: i16,
177        flex: bool,
178    ) -> Result<(), ProtocolError> {
179        if version >= 0 {
180            if flex {
181                put_compact_string(buf, &self.group_id)?;
182            } else {
183                put_string(buf, &self.group_id)?;
184            }
185        }
186        Ok(())
187    }
188    fn encode_field_3<B: BufMut>(
189        &self,
190        buf: &mut B,
191        version: i16,
192        flex: bool,
193    ) -> Result<(), ProtocolError> {
194        if version >= 0 {
195            if flex {
196                put_compact_string(buf, &self.group_state)?;
197            } else {
198                put_string(buf, &self.group_state)?;
199            }
200        }
201        Ok(())
202    }
203    fn encode_field_4<B: BufMut>(&self, buf: &mut B, version: i16, _flex: bool) {
204        if version >= 0 {
205            put_i32(buf, self.group_epoch);
206        }
207    }
208    fn encode_field_5<B: BufMut>(&self, buf: &mut B, version: i16, _flex: bool) {
209        if version >= 0 {
210            put_i32(buf, self.assignment_epoch);
211        }
212    }
213    fn encode_field_6<B: BufMut>(
214        &self,
215        buf: &mut B,
216        version: i16,
217        flex: bool,
218    ) -> Result<(), ProtocolError> {
219        if version >= 0 {
220            if flex {
221                put_compact_string(buf, &self.assignor_name)?;
222            } else {
223                put_string(buf, &self.assignor_name)?;
224            }
225        }
226        Ok(())
227    }
228    fn encode_field_7<B: BufMut>(
229        &self,
230        buf: &mut B,
231        version: i16,
232        flex: bool,
233    ) -> Result<(), ProtocolError> {
234        if version >= 0 {
235            {
236                put_array_len(buf, (self.members).len(), flex)?;
237                for it in &self.members {
238                    it.encode(buf, version)?;
239                }
240            }
241        }
242        Ok(())
243    }
244    fn encode_field_8<B: BufMut>(&self, buf: &mut B, version: i16, _flex: bool) {
245        if version >= 0 {
246            put_i32(buf, self.authorized_operations);
247        }
248    }
249    fn encode_tagged_fields<B: BufMut>(
250        &self,
251        buf: &mut B,
252        _version: i16,
253        flex: bool,
254    ) -> Result<(), ProtocolError> {
255        if flex {
256            let tagged = WriteTaggedFields::new();
257            tagged.write(buf, &self.unknown_tagged_fields)?;
258        }
259        Ok(())
260    }
261    fn decode_field_0<B: Buf>(
262        out: &mut Self,
263        buf: &mut B,
264        version: i16,
265        _flex: bool,
266    ) -> Result<(), ProtocolError> {
267        if version >= 0 {
268            out.error_code = get_i16(buf)?;
269        }
270        Ok(())
271    }
272    fn decode_field_1<B: Buf>(
273        out: &mut Self,
274        buf: &mut B,
275        version: i16,
276        flex: bool,
277    ) -> Result<(), ProtocolError> {
278        if version >= 0 {
279            out.error_message = if flex {
280                get_compact_nullable_string_owned(buf)?
281            } else {
282                get_nullable_string_owned(buf)?
283            };
284        }
285        Ok(())
286    }
287    fn decode_field_2<B: Buf>(
288        out: &mut Self,
289        buf: &mut B,
290        version: i16,
291        flex: bool,
292    ) -> Result<(), ProtocolError> {
293        if version >= 0 {
294            out.group_id = if flex {
295                get_compact_string_owned(buf)?
296            } else {
297                get_string_owned(buf)?
298            };
299        }
300        Ok(())
301    }
302    fn decode_field_3<B: Buf>(
303        out: &mut Self,
304        buf: &mut B,
305        version: i16,
306        flex: bool,
307    ) -> Result<(), ProtocolError> {
308        if version >= 0 {
309            out.group_state = if flex {
310                get_compact_string_owned(buf)?
311            } else {
312                get_string_owned(buf)?
313            };
314        }
315        Ok(())
316    }
317    fn decode_field_4<B: Buf>(
318        out: &mut Self,
319        buf: &mut B,
320        version: i16,
321        _flex: bool,
322    ) -> Result<(), ProtocolError> {
323        if version >= 0 {
324            out.group_epoch = get_i32(buf)?;
325        }
326        Ok(())
327    }
328    fn decode_field_5<B: Buf>(
329        out: &mut Self,
330        buf: &mut B,
331        version: i16,
332        _flex: bool,
333    ) -> Result<(), ProtocolError> {
334        if version >= 0 {
335            out.assignment_epoch = get_i32(buf)?;
336        }
337        Ok(())
338    }
339    fn decode_field_6<B: Buf>(
340        out: &mut Self,
341        buf: &mut B,
342        version: i16,
343        flex: bool,
344    ) -> Result<(), ProtocolError> {
345        if version >= 0 {
346            out.assignor_name = if flex {
347                get_compact_string_owned(buf)?
348            } else {
349                get_string_owned(buf)?
350            };
351        }
352        Ok(())
353    }
354    fn decode_field_7<B: Buf>(
355        out: &mut Self,
356        buf: &mut B,
357        version: i16,
358        flex: bool,
359    ) -> Result<(), ProtocolError> {
360        if version >= 0 {
361            out.members = {
362                let n = get_array_len(buf, flex)?;
363                let mut v = Vec::with_capacity(n);
364                for _ in 0..n {
365                    v.push(Member::decode(buf, version)?);
366                }
367                v
368            };
369        }
370        Ok(())
371    }
372    fn decode_field_8<B: Buf>(
373        out: &mut Self,
374        buf: &mut B,
375        version: i16,
376        _flex: bool,
377    ) -> Result<(), ProtocolError> {
378        if version >= 0 {
379            out.authorized_operations = get_i32(buf)?;
380        }
381        Ok(())
382    }
383    fn decode_tagged_fields<B: Buf>(
384        out: &mut Self,
385        buf: &mut B,
386        _version: i16,
387        flex: bool,
388    ) -> Result<(), ProtocolError> {
389        if flex {
390            out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
391        }
392        Ok(())
393    }
394}
395impl Encode for DescribedGroup {
396    fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
397        let flex = version >= 0;
398        self.encode_field_0(buf, version, flex);
399        self.encode_field_1(buf, version, flex)?;
400        self.encode_field_2(buf, version, flex)?;
401        self.encode_field_3(buf, version, flex)?;
402        self.encode_field_4(buf, version, flex);
403        self.encode_field_5(buf, version, flex);
404        self.encode_field_6(buf, version, flex)?;
405        self.encode_field_7(buf, version, flex)?;
406        self.encode_field_8(buf, version, flex);
407        self.encode_tagged_fields(buf, version, flex)?;
408        Ok(())
409    }
410    fn encoded_len(&self, version: i16) -> usize {
411        let flex = version >= 0;
412        let mut n: usize = 0;
413        if version >= 0 {
414            n += 2;
415        }
416        if version >= 0 {
417            n += if flex {
418                compact_nullable_string_len(self.error_message.as_deref())
419            } else {
420                nullable_string_len(self.error_message.as_deref())
421            };
422        }
423        if version >= 0 {
424            n += if flex {
425                compact_string_len(&self.group_id)
426            } else {
427                string_len(&self.group_id)
428            };
429        }
430        if version >= 0 {
431            n += if flex {
432                compact_string_len(&self.group_state)
433            } else {
434                string_len(&self.group_state)
435            };
436        }
437        if version >= 0 {
438            n += 4;
439        }
440        if version >= 0 {
441            n += 4;
442        }
443        if version >= 0 {
444            n += if flex {
445                compact_string_len(&self.assignor_name)
446            } else {
447                string_len(&self.assignor_name)
448            };
449        }
450        if version >= 0 {
451            n += {
452                let prefix = array_len_prefix_len((self.members).len(), flex);
453                let body: usize = (self.members)
454                    .iter()
455                    .map(|it| it.encoded_len(version))
456                    .sum();
457                prefix + body
458            };
459        }
460        if version >= 0 {
461            n += 4;
462        }
463        if flex {
464            let known_pairs: Vec<(u32, usize)> = Vec::new();
465            n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
466        }
467        n
468    }
469}
470impl Decode<'_> for DescribedGroup {
471    fn decode<B: Buf>(buf: &mut B, version: i16) -> Result<Self, ProtocolError> {
472        let flex = version >= 0;
473        let mut out = Self::default();
474        Self::decode_field_0(&mut out, buf, version, flex)?;
475        Self::decode_field_1(&mut out, buf, version, flex)?;
476        Self::decode_field_2(&mut out, buf, version, flex)?;
477        Self::decode_field_3(&mut out, buf, version, flex)?;
478        Self::decode_field_4(&mut out, buf, version, flex)?;
479        Self::decode_field_5(&mut out, buf, version, flex)?;
480        Self::decode_field_6(&mut out, buf, version, flex)?;
481        Self::decode_field_7(&mut out, buf, version, flex)?;
482        Self::decode_field_8(&mut out, buf, version, flex)?;
483        Self::decode_tagged_fields(&mut out, buf, version, flex)?;
484        Ok(out)
485    }
486}
487#[cfg(test)]
488impl DescribedGroup {
489    #[must_use]
490    pub fn populated(version: i16) -> Self {
491        let mut m = Self::default();
492        if version >= 0 {
493            m.error_code = 1i16;
494        }
495        if version >= 0 {
496            m.error_message = Some("x".to_owned());
497        }
498        if version >= 0 {
499            m.group_id = "x".to_owned();
500        }
501        if version >= 0 {
502            m.group_state = "x".to_owned();
503        }
504        if version >= 0 {
505            m.group_epoch = 1i32;
506        }
507        if version >= 0 {
508            m.assignment_epoch = 1i32;
509        }
510        if version >= 0 {
511            m.assignor_name = "x".to_owned();
512        }
513        if version >= 0 {
514            m.members = vec![Member::populated(version)];
515        }
516        if version >= 0 {
517            m.authorized_operations = 1i32;
518        }
519        m
520    }
521}
522#[derive(Debug, Clone, PartialEq, Eq)]
523pub struct Member {
524    pub member_id: String,
525    pub instance_id: Option<String>,
526    pub rack_id: Option<String>,
527    pub member_epoch: i32,
528    pub client_id: String,
529    pub client_host: String,
530    pub subscribed_topic_names: Vec<String>,
531    pub subscribed_topic_regex: Option<String>,
532    pub assignment: super::common::consumer_group_describe_response::assignment::Assignment,
533    pub target_assignment: super::common::consumer_group_describe_response::assignment::Assignment,
534    pub member_type: i8,
535    pub unknown_tagged_fields: UnknownTaggedFields,
536}
537impl Default for Member {
538    fn default() -> Self {
539        Self {
540            member_id: String::new(),
541            instance_id: None,
542            rack_id: None,
543            member_epoch: 0i32,
544            client_id: String::new(),
545            client_host: String::new(),
546            subscribed_topic_names: Vec::new(),
547            subscribed_topic_regex: None,
548            assignment:
549                super::common::consumer_group_describe_response::assignment::Assignment::default(),
550            target_assignment:
551                super::common::consumer_group_describe_response::assignment::Assignment::default(),
552            member_type: -1i8,
553            unknown_tagged_fields: UnknownTaggedFields::default(),
554        }
555    }
556}
557impl Member {
558    fn encode_field_0<B: BufMut>(
559        &self,
560        buf: &mut B,
561        version: i16,
562        flex: bool,
563    ) -> Result<(), ProtocolError> {
564        if version >= 0 {
565            if flex {
566                put_compact_string(buf, &self.member_id)?;
567            } else {
568                put_string(buf, &self.member_id)?;
569            }
570        }
571        Ok(())
572    }
573    fn encode_field_1<B: BufMut>(
574        &self,
575        buf: &mut B,
576        version: i16,
577        flex: bool,
578    ) -> Result<(), ProtocolError> {
579        if version >= 0 {
580            if flex {
581                put_compact_nullable_string(buf, self.instance_id.as_deref())?;
582            } else {
583                put_nullable_string(buf, self.instance_id.as_deref())?;
584            }
585        }
586        Ok(())
587    }
588    fn encode_field_2<B: BufMut>(
589        &self,
590        buf: &mut B,
591        version: i16,
592        flex: bool,
593    ) -> Result<(), ProtocolError> {
594        if version >= 0 {
595            if flex {
596                put_compact_nullable_string(buf, self.rack_id.as_deref())?;
597            } else {
598                put_nullable_string(buf, self.rack_id.as_deref())?;
599            }
600        }
601        Ok(())
602    }
603    fn encode_field_3<B: BufMut>(&self, buf: &mut B, version: i16, _flex: bool) {
604        if version >= 0 {
605            put_i32(buf, self.member_epoch);
606        }
607    }
608    fn encode_field_4<B: BufMut>(
609        &self,
610        buf: &mut B,
611        version: i16,
612        flex: bool,
613    ) -> Result<(), ProtocolError> {
614        if version >= 0 {
615            if flex {
616                put_compact_string(buf, &self.client_id)?;
617            } else {
618                put_string(buf, &self.client_id)?;
619            }
620        }
621        Ok(())
622    }
623    fn encode_field_5<B: BufMut>(
624        &self,
625        buf: &mut B,
626        version: i16,
627        flex: bool,
628    ) -> Result<(), ProtocolError> {
629        if version >= 0 {
630            if flex {
631                put_compact_string(buf, &self.client_host)?;
632            } else {
633                put_string(buf, &self.client_host)?;
634            }
635        }
636        Ok(())
637    }
638    fn encode_field_6<B: BufMut>(
639        &self,
640        buf: &mut B,
641        version: i16,
642        flex: bool,
643    ) -> Result<(), ProtocolError> {
644        if version >= 0 {
645            {
646                put_array_len(buf, (self.subscribed_topic_names).len(), flex)?;
647                for it in &self.subscribed_topic_names {
648                    if flex {
649                        put_compact_string(buf, it)?;
650                    } else {
651                        put_string(buf, it)?;
652                    }
653                }
654            }
655        }
656        Ok(())
657    }
658    fn encode_field_7<B: BufMut>(
659        &self,
660        buf: &mut B,
661        version: i16,
662        flex: bool,
663    ) -> Result<(), ProtocolError> {
664        if version >= 0 {
665            if flex {
666                put_compact_nullable_string(buf, self.subscribed_topic_regex.as_deref())?;
667            } else {
668                put_nullable_string(buf, self.subscribed_topic_regex.as_deref())?;
669            }
670        }
671        Ok(())
672    }
673    fn encode_field_8<B: BufMut>(
674        &self,
675        buf: &mut B,
676        version: i16,
677        _flex: bool,
678    ) -> Result<(), ProtocolError> {
679        if version >= 0 {
680            self.assignment.encode(buf, version)?;
681        }
682        Ok(())
683    }
684    fn encode_field_9<B: BufMut>(
685        &self,
686        buf: &mut B,
687        version: i16,
688        _flex: bool,
689    ) -> Result<(), ProtocolError> {
690        if version >= 0 {
691            self.target_assignment.encode(buf, version)?;
692        }
693        Ok(())
694    }
695    fn encode_field_10<B: BufMut>(&self, buf: &mut B, version: i16, _flex: bool) {
696        if version >= 1 {
697            put_i8(buf, self.member_type);
698        }
699    }
700    fn encode_tagged_fields<B: BufMut>(
701        &self,
702        buf: &mut B,
703        _version: i16,
704        flex: bool,
705    ) -> Result<(), ProtocolError> {
706        if flex {
707            let tagged = WriteTaggedFields::new();
708            tagged.write(buf, &self.unknown_tagged_fields)?;
709        }
710        Ok(())
711    }
712    fn decode_field_0<B: Buf>(
713        out: &mut Self,
714        buf: &mut B,
715        version: i16,
716        flex: bool,
717    ) -> Result<(), ProtocolError> {
718        if version >= 0 {
719            out.member_id = if flex {
720                get_compact_string_owned(buf)?
721            } else {
722                get_string_owned(buf)?
723            };
724        }
725        Ok(())
726    }
727    fn decode_field_1<B: Buf>(
728        out: &mut Self,
729        buf: &mut B,
730        version: i16,
731        flex: bool,
732    ) -> Result<(), ProtocolError> {
733        if version >= 0 {
734            out.instance_id = if flex {
735                get_compact_nullable_string_owned(buf)?
736            } else {
737                get_nullable_string_owned(buf)?
738            };
739        }
740        Ok(())
741    }
742    fn decode_field_2<B: Buf>(
743        out: &mut Self,
744        buf: &mut B,
745        version: i16,
746        flex: bool,
747    ) -> Result<(), ProtocolError> {
748        if version >= 0 {
749            out.rack_id = if flex {
750                get_compact_nullable_string_owned(buf)?
751            } else {
752                get_nullable_string_owned(buf)?
753            };
754        }
755        Ok(())
756    }
757    fn decode_field_3<B: Buf>(
758        out: &mut Self,
759        buf: &mut B,
760        version: i16,
761        _flex: bool,
762    ) -> Result<(), ProtocolError> {
763        if version >= 0 {
764            out.member_epoch = get_i32(buf)?;
765        }
766        Ok(())
767    }
768    fn decode_field_4<B: Buf>(
769        out: &mut Self,
770        buf: &mut B,
771        version: i16,
772        flex: bool,
773    ) -> Result<(), ProtocolError> {
774        if version >= 0 {
775            out.client_id = if flex {
776                get_compact_string_owned(buf)?
777            } else {
778                get_string_owned(buf)?
779            };
780        }
781        Ok(())
782    }
783    fn decode_field_5<B: Buf>(
784        out: &mut Self,
785        buf: &mut B,
786        version: i16,
787        flex: bool,
788    ) -> Result<(), ProtocolError> {
789        if version >= 0 {
790            out.client_host = if flex {
791                get_compact_string_owned(buf)?
792            } else {
793                get_string_owned(buf)?
794            };
795        }
796        Ok(())
797    }
798    fn decode_field_6<B: Buf>(
799        out: &mut Self,
800        buf: &mut B,
801        version: i16,
802        flex: bool,
803    ) -> Result<(), ProtocolError> {
804        if version >= 0 {
805            out.subscribed_topic_names = {
806                let n = get_array_len(buf, flex)?;
807                let mut v = Vec::with_capacity(n);
808                for _ in 0..n {
809                    v.push(if flex {
810                        get_compact_string_owned(buf)?
811                    } else {
812                        get_string_owned(buf)?
813                    });
814                }
815                v
816            };
817        }
818        Ok(())
819    }
820    fn decode_field_7<B: Buf>(
821        out: &mut Self,
822        buf: &mut B,
823        version: i16,
824        flex: bool,
825    ) -> Result<(), ProtocolError> {
826        if version >= 0 {
827            out.subscribed_topic_regex = if flex {
828                get_compact_nullable_string_owned(buf)?
829            } else {
830                get_nullable_string_owned(buf)?
831            };
832        }
833        Ok(())
834    }
835    fn decode_field_8<B: Buf>(
836        out: &mut Self,
837        buf: &mut B,
838        version: i16,
839        _flex: bool,
840    ) -> Result<(), ProtocolError> {
841        if version >= 0 {
842            out.assignment =
843                super::common::consumer_group_describe_response::assignment::Assignment::decode(
844                    buf, version,
845                )?;
846        }
847        Ok(())
848    }
849    fn decode_field_9<B: Buf>(
850        out: &mut Self,
851        buf: &mut B,
852        version: i16,
853        _flex: bool,
854    ) -> Result<(), ProtocolError> {
855        if version >= 0 {
856            out.target_assignment =
857                super::common::consumer_group_describe_response::assignment::Assignment::decode(
858                    buf, version,
859                )?;
860        }
861        Ok(())
862    }
863    fn decode_field_10<B: Buf>(
864        out: &mut Self,
865        buf: &mut B,
866        version: i16,
867        _flex: bool,
868    ) -> Result<(), ProtocolError> {
869        if version >= 1 {
870            out.member_type = get_i8(buf)?;
871        }
872        Ok(())
873    }
874    fn decode_tagged_fields<B: Buf>(
875        out: &mut Self,
876        buf: &mut B,
877        _version: i16,
878        flex: bool,
879    ) -> Result<(), ProtocolError> {
880        if flex {
881            out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
882        }
883        Ok(())
884    }
885}
886impl Encode for Member {
887    fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
888        let flex = version >= 0;
889        self.encode_field_0(buf, version, flex)?;
890        self.encode_field_1(buf, version, flex)?;
891        self.encode_field_2(buf, version, flex)?;
892        self.encode_field_3(buf, version, flex);
893        self.encode_field_4(buf, version, flex)?;
894        self.encode_field_5(buf, version, flex)?;
895        self.encode_field_6(buf, version, flex)?;
896        self.encode_field_7(buf, version, flex)?;
897        self.encode_field_8(buf, version, flex)?;
898        self.encode_field_9(buf, version, flex)?;
899        self.encode_field_10(buf, version, flex);
900        self.encode_tagged_fields(buf, version, flex)?;
901        Ok(())
902    }
903    fn encoded_len(&self, version: i16) -> usize {
904        let flex = version >= 0;
905        let mut n: usize = 0;
906        if version >= 0 {
907            n += if flex {
908                compact_string_len(&self.member_id)
909            } else {
910                string_len(&self.member_id)
911            };
912        }
913        if version >= 0 {
914            n += if flex {
915                compact_nullable_string_len(self.instance_id.as_deref())
916            } else {
917                nullable_string_len(self.instance_id.as_deref())
918            };
919        }
920        if version >= 0 {
921            n += if flex {
922                compact_nullable_string_len(self.rack_id.as_deref())
923            } else {
924                nullable_string_len(self.rack_id.as_deref())
925            };
926        }
927        if version >= 0 {
928            n += 4;
929        }
930        if version >= 0 {
931            n += if flex {
932                compact_string_len(&self.client_id)
933            } else {
934                string_len(&self.client_id)
935            };
936        }
937        if version >= 0 {
938            n += if flex {
939                compact_string_len(&self.client_host)
940            } else {
941                string_len(&self.client_host)
942            };
943        }
944        if version >= 0 {
945            n += {
946                let prefix = array_len_prefix_len((self.subscribed_topic_names).len(), flex);
947                let body: usize = (self.subscribed_topic_names)
948                    .iter()
949                    .map(|it| {
950                        if flex {
951                            compact_string_len(it)
952                        } else {
953                            string_len(it)
954                        }
955                    })
956                    .sum();
957                prefix + body
958            };
959        }
960        if version >= 0 {
961            n += if flex {
962                compact_nullable_string_len(self.subscribed_topic_regex.as_deref())
963            } else {
964                nullable_string_len(self.subscribed_topic_regex.as_deref())
965            };
966        }
967        if version >= 0 {
968            n += self.assignment.encoded_len(version);
969        }
970        if version >= 0 {
971            n += self.target_assignment.encoded_len(version);
972        }
973        if version >= 1 {
974            n += 1;
975        }
976        if flex {
977            let known_pairs: Vec<(u32, usize)> = Vec::new();
978            n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
979        }
980        n
981    }
982}
983impl Decode<'_> for Member {
984    fn decode<B: Buf>(buf: &mut B, version: i16) -> Result<Self, ProtocolError> {
985        let flex = version >= 0;
986        let mut out = Self::default();
987        Self::decode_field_0(&mut out, buf, version, flex)?;
988        Self::decode_field_1(&mut out, buf, version, flex)?;
989        Self::decode_field_2(&mut out, buf, version, flex)?;
990        Self::decode_field_3(&mut out, buf, version, flex)?;
991        Self::decode_field_4(&mut out, buf, version, flex)?;
992        Self::decode_field_5(&mut out, buf, version, flex)?;
993        Self::decode_field_6(&mut out, buf, version, flex)?;
994        Self::decode_field_7(&mut out, buf, version, flex)?;
995        Self::decode_field_8(&mut out, buf, version, flex)?;
996        Self::decode_field_9(&mut out, buf, version, flex)?;
997        Self::decode_field_10(&mut out, buf, version, flex)?;
998        Self::decode_tagged_fields(&mut out, buf, version, flex)?;
999        Ok(out)
1000    }
1001}
1002#[cfg(test)]
1003impl Member {
1004    #[must_use]
1005    pub fn populated(version: i16) -> Self {
1006        let mut m = Self::default();
1007        if version >= 0 {
1008            m.member_id = "x".to_owned();
1009        }
1010        if version >= 0 {
1011            m.instance_id = Some("x".to_owned());
1012        }
1013        if version >= 0 {
1014            m.rack_id = Some("x".to_owned());
1015        }
1016        if version >= 0 {
1017            m.member_epoch = 1i32;
1018        }
1019        if version >= 0 {
1020            m.client_id = "x".to_owned();
1021        }
1022        if version >= 0 {
1023            m.client_host = "x".to_owned();
1024        }
1025        if version >= 0 {
1026            m.subscribed_topic_names = vec!["x".to_owned()];
1027        }
1028        if version >= 0 {
1029            m.subscribed_topic_regex = Some("x".to_owned());
1030        }
1031        if version >= 0 {
1032            m.assignment =
1033                super::common::consumer_group_describe_response::assignment::Assignment::populated(
1034                    version,
1035                );
1036        }
1037        if version >= 0 {
1038            m.target_assignment =
1039                super::common::consumer_group_describe_response::assignment::Assignment::populated(
1040                    version,
1041                );
1042        }
1043        if version >= 1 {
1044            m.member_type = 1i8;
1045        }
1046        m
1047    }
1048}
1049/// Default JSON payload matching `Self::default()` for JVM oracle differential testing.
1050/// Only includes fields valid for the given version.
1051#[must_use]
1052#[allow(unused_comparisons)]
1053pub fn default_json(_version: i16) -> ::serde_json::Value {
1054    let mut obj = ::serde_json::Map::new();
1055    obj.insert("throttleTimeMs".to_owned(), ::serde_json::json!(0));
1056    obj.insert("groups".to_owned(), ::serde_json::Value::Array(vec![]));
1057    ::serde_json::Value::Object(obj)
1058}