Skip to main content

kacrab_protocol/generated/
streams_group_describe_response.rs

1//! Generated from StreamsGroupDescribeResponse.json - DO NOT EDIT
2#![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 StreamsGroupDescribeResponseData {
17    /// The duration in milliseconds for which the request was throttled due to a quota violation,
18    /// or zero if the request did not violate any quota.
19    pub throttle_time_ms: i32,
20    /// Each described group.
21    pub groups: Vec<DescribedGroup>,
22    pub _unknown_tagged_fields: Vec<RawTaggedField>,
23}
24impl Default for StreamsGroupDescribeResponseData {
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 StreamsGroupDescribeResponseData {
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 < 0 || version > 0 {
44            return Err(UnsupportedVersion::new(89, 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 < 0 || version > 0 {
74            return Err(UnsupportedVersion::new(89, 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 < 0 || version > 0 {
88            return Err(UnsupportedVersion::new(89, 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    /// The describe error, or 0 if there was no error.
105    pub error_code: i16,
106    /// The top-level error message, or null if there was no error.
107    pub error_message: Option<KafkaString>,
108    /// The group ID string.
109    pub group_id: KafkaString,
110    /// The group state string, or the empty string.
111    pub group_state: KafkaString,
112    /// The group epoch.
113    pub group_epoch: i32,
114    /// The assignment epoch.
115    pub assignment_epoch: i32,
116    /// The topology metadata currently initialized for the streams application. Can be null in
117    /// case of a describe error.
118    pub topology: Option<Box<Topology>>,
119    /// The members.
120    pub members: Vec<Member>,
121    /// 32-bit bitfield to represent authorized operations for this group.
122    pub authorized_operations: i32,
123    pub _unknown_tagged_fields: Vec<RawTaggedField>,
124}
125impl Default for DescribedGroup {
126    fn default() -> Self {
127        Self {
128            error_code: 0_i16,
129            error_message: None,
130            group_id: KafkaString::default(),
131            group_state: KafkaString::default(),
132            group_epoch: 0_i32,
133            assignment_epoch: 0_i32,
134            topology: None,
135            members: Vec::new(),
136            authorized_operations: i32::MIN,
137            _unknown_tagged_fields: Vec::new(),
138        }
139    }
140}
141impl DescribedGroup {
142    pub fn with_error_code(mut self, value: i16) -> Self {
143        self.error_code = value;
144        self
145    }
146    pub fn with_error_message(mut self, value: Option<KafkaString>) -> Self {
147        self.error_message = value;
148        self
149    }
150    pub fn with_group_id(mut self, value: KafkaString) -> Self {
151        self.group_id = value;
152        self
153    }
154    pub fn with_group_state(mut self, value: KafkaString) -> Self {
155        self.group_state = value;
156        self
157    }
158    pub fn with_group_epoch(mut self, value: i32) -> Self {
159        self.group_epoch = value;
160        self
161    }
162    pub fn with_assignment_epoch(mut self, value: i32) -> Self {
163        self.assignment_epoch = value;
164        self
165    }
166    pub fn with_topology(mut self, value: Option<Box<Topology>>) -> Self {
167        self.topology = value;
168        self
169    }
170    pub fn with_members(mut self, value: Vec<Member>) -> Self {
171        self.members = value;
172        self
173    }
174    pub fn with_authorized_operations(mut self, value: i32) -> Self {
175        self.authorized_operations = value;
176        self
177    }
178    pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
179        let error_code;
180        let error_message;
181        let group_id;
182        let group_state;
183        let group_epoch;
184        let assignment_epoch;
185        let topology;
186        let members;
187        let authorized_operations;
188        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
189        error_code = read_i16(buf)?;
190        error_message = read_compact_nullable_string(buf)?;
191        group_id = read_compact_string(buf)?;
192        group_state = read_compact_string(buf)?;
193        group_epoch = read_i32(buf)?;
194        assignment_epoch = read_i32(buf)?;
195        topology = {
196            let marker = read_i8(buf)?;
197            if marker < 0 {
198                None
199            } else {
200                Some(Box::new(Topology::read(buf, version)?))
201            }
202        };
203        members = {
204            let len = read_compact_array_length(buf)?;
205            let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
206            for _ in 0..len {
207                arr.push(Member::read(buf, version)?);
208            }
209            arr
210        };
211        authorized_operations = read_i32(buf)?;
212        let tagged_fields = read_tagged_fields(buf)?;
213        for field in &tagged_fields {
214            match field.tag {
215                _ => {
216                    _unknown_tagged_fields.push(field.clone());
217                },
218            }
219        }
220        Ok(Self {
221            error_code,
222            error_message,
223            group_id,
224            group_state,
225            group_epoch,
226            assignment_epoch,
227            topology,
228            members,
229            authorized_operations,
230            _unknown_tagged_fields,
231        })
232    }
233    pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
234        write_i16(buf, self.error_code);
235        write_compact_nullable_string(buf, self.error_message.as_ref())?;
236        write_compact_string(buf, &self.group_id)?;
237        write_compact_string(buf, &self.group_state)?;
238        write_i32(buf, self.group_epoch);
239        write_i32(buf, self.assignment_epoch);
240        match &self.topology {
241            None => {
242                write_i8(buf, -1);
243            },
244            Some(v) => {
245                write_i8(buf, 1);
246                v.write(buf, version)?;
247            },
248        }
249        write_compact_array_length(buf, self.members.len() as i32);
250        for el in &self.members {
251            el.write(buf, version)?;
252        }
253        write_i32(buf, self.authorized_operations);
254        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
255        all_tags.sort_by_key(|f| f.tag);
256        write_tagged_fields(buf, &all_tags)?;
257        Ok(())
258    }
259    pub fn encoded_len(&self, version: i16) -> Result<usize> {
260        let mut len: usize = 0;
261        len += 2;
262        len += compact_nullable_string_len(self.error_message.as_ref())?;
263        len += compact_string_len(&self.group_id)?;
264        len += compact_string_len(&self.group_state)?;
265        len += 4;
266        len += 4;
267        match &self.topology {
268            None => {
269                len += 1;
270            },
271            Some(v) => {
272                len += 1;
273                len += v.encoded_len(version)?;
274            },
275        }
276        len += compact_array_length_len(self.members.len() as i32);
277        for el in &self.members {
278            len += el.encoded_len(version)?;
279        }
280        len += 4;
281        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
282        all_tags.sort_by_key(|f| f.tag);
283        len += tagged_fields_len(&all_tags)?;
284        Ok(len)
285    }
286}
287#[derive(Debug, Clone, PartialEq)]
288pub struct Topology {
289    /// The epoch of the currently initialized topology for this group.
290    pub epoch: i32,
291    /// The subtopologies of the streams application. This contains the configured subtopologies,
292    /// where the number of partitions are set and any regular expressions are resolved to actual
293    /// topics. Null if the group is uninitialized, source topics are missing or incorrectly
294    /// partitioned.
295    pub subtopologies: Option<Vec<Subtopology>>,
296    pub _unknown_tagged_fields: Vec<RawTaggedField>,
297}
298impl Default for Topology {
299    fn default() -> Self {
300        Self {
301            epoch: 0_i32,
302            subtopologies: None,
303            _unknown_tagged_fields: Vec::new(),
304        }
305    }
306}
307impl Topology {
308    pub fn with_epoch(mut self, value: i32) -> Self {
309        self.epoch = value;
310        self
311    }
312    pub fn with_subtopologies(mut self, value: Option<Vec<Subtopology>>) -> Self {
313        self.subtopologies = value;
314        self
315    }
316    pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
317        let epoch;
318        let subtopologies;
319        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
320        epoch = read_i32(buf)?;
321        subtopologies = {
322            let len = read_compact_array_length(buf)?;
323            if len < 0 {
324                None
325            } else {
326                let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
327                for _ in 0..len {
328                    arr.push(Subtopology::read(buf, version)?);
329                }
330                Some(arr)
331            }
332        };
333        let tagged_fields = read_tagged_fields(buf)?;
334        for field in &tagged_fields {
335            match field.tag {
336                _ => {
337                    _unknown_tagged_fields.push(field.clone());
338                },
339            }
340        }
341        Ok(Self {
342            epoch,
343            subtopologies,
344            _unknown_tagged_fields,
345        })
346    }
347    pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
348        write_i32(buf, self.epoch);
349        match &self.subtopologies {
350            None => {
351                write_compact_array_length(buf, -1);
352            },
353            Some(arr) => {
354                write_compact_array_length(buf, arr.len() as i32);
355                for el in arr {
356                    el.write(buf, version)?;
357                }
358            },
359        }
360        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
361        all_tags.sort_by_key(|f| f.tag);
362        write_tagged_fields(buf, &all_tags)?;
363        Ok(())
364    }
365    pub fn encoded_len(&self, version: i16) -> Result<usize> {
366        let mut len: usize = 0;
367        len += 4;
368        match &self.subtopologies {
369            None => {
370                len += compact_array_length_len(-1);
371            },
372            Some(arr) => {
373                len += compact_array_length_len(arr.len() as i32);
374                for el in arr {
375                    len += el.encoded_len(version)?;
376                }
377            },
378        }
379        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
380        all_tags.sort_by_key(|f| f.tag);
381        len += tagged_fields_len(&all_tags)?;
382        Ok(len)
383    }
384}
385#[derive(Debug, Clone, PartialEq)]
386pub struct Subtopology {
387    /// String to uniquely identify the subtopology.
388    pub subtopology_id: KafkaString,
389    /// The topics the subtopology reads from.
390    pub source_topics: Vec<KafkaString>,
391    /// The repartition topics the subtopology writes to.
392    pub repartition_sink_topics: Vec<KafkaString>,
393    /// The set of state changelog topics associated with this subtopology. Created automatically.
394    pub state_changelog_topics: Vec<TopicInfo>,
395    /// The set of source topics that are internally created repartition topics. Created
396    /// automatically.
397    pub repartition_source_topics: Vec<TopicInfo>,
398    pub _unknown_tagged_fields: Vec<RawTaggedField>,
399}
400impl Default for Subtopology {
401    fn default() -> Self {
402        Self {
403            subtopology_id: KafkaString::default(),
404            source_topics: Vec::new(),
405            repartition_sink_topics: Vec::new(),
406            state_changelog_topics: Vec::new(),
407            repartition_source_topics: Vec::new(),
408            _unknown_tagged_fields: Vec::new(),
409        }
410    }
411}
412impl Subtopology {
413    pub fn with_subtopology_id(mut self, value: KafkaString) -> Self {
414        self.subtopology_id = value;
415        self
416    }
417    pub fn with_source_topics(mut self, value: Vec<KafkaString>) -> Self {
418        self.source_topics = value;
419        self
420    }
421    pub fn with_repartition_sink_topics(mut self, value: Vec<KafkaString>) -> Self {
422        self.repartition_sink_topics = value;
423        self
424    }
425    pub fn with_state_changelog_topics(mut self, value: Vec<TopicInfo>) -> Self {
426        self.state_changelog_topics = value;
427        self
428    }
429    pub fn with_repartition_source_topics(mut self, value: Vec<TopicInfo>) -> Self {
430        self.repartition_source_topics = value;
431        self
432    }
433    pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
434        let subtopology_id;
435        let source_topics;
436        let repartition_sink_topics;
437        let state_changelog_topics;
438        let repartition_source_topics;
439        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
440        subtopology_id = read_compact_string(buf)?;
441        source_topics = {
442            let len = read_compact_array_length(buf)?;
443            let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
444            for _ in 0..len {
445                arr.push(read_compact_string(buf)?);
446            }
447            arr
448        };
449        repartition_sink_topics = {
450            let len = read_compact_array_length(buf)?;
451            let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
452            for _ in 0..len {
453                arr.push(read_compact_string(buf)?);
454            }
455            arr
456        };
457        state_changelog_topics = {
458            let len = read_compact_array_length(buf)?;
459            let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
460            for _ in 0..len {
461                arr.push(TopicInfo::read(buf, version)?);
462            }
463            arr
464        };
465        repartition_source_topics = {
466            let len = read_compact_array_length(buf)?;
467            let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
468            for _ in 0..len {
469                arr.push(TopicInfo::read(buf, version)?);
470            }
471            arr
472        };
473        let tagged_fields = read_tagged_fields(buf)?;
474        for field in &tagged_fields {
475            match field.tag {
476                _ => {
477                    _unknown_tagged_fields.push(field.clone());
478                },
479            }
480        }
481        Ok(Self {
482            subtopology_id,
483            source_topics,
484            repartition_sink_topics,
485            state_changelog_topics,
486            repartition_source_topics,
487            _unknown_tagged_fields,
488        })
489    }
490    pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
491        write_compact_string(buf, &self.subtopology_id)?;
492        write_compact_array_length(buf, self.source_topics.len() as i32);
493        for el in &self.source_topics {
494            write_compact_string(buf, el)?;
495        }
496        write_compact_array_length(buf, self.repartition_sink_topics.len() as i32);
497        for el in &self.repartition_sink_topics {
498            write_compact_string(buf, el)?;
499        }
500        write_compact_array_length(buf, self.state_changelog_topics.len() as i32);
501        for el in &self.state_changelog_topics {
502            el.write(buf, version)?;
503        }
504        write_compact_array_length(buf, self.repartition_source_topics.len() as i32);
505        for el in &self.repartition_source_topics {
506            el.write(buf, version)?;
507        }
508        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
509        all_tags.sort_by_key(|f| f.tag);
510        write_tagged_fields(buf, &all_tags)?;
511        Ok(())
512    }
513    pub fn encoded_len(&self, version: i16) -> Result<usize> {
514        let mut len: usize = 0;
515        len += compact_string_len(&self.subtopology_id)?;
516        len += compact_array_length_len(self.source_topics.len() as i32);
517        for el in &self.source_topics {
518            len += compact_string_len(el)?;
519        }
520        len += compact_array_length_len(self.repartition_sink_topics.len() as i32);
521        for el in &self.repartition_sink_topics {
522            len += compact_string_len(el)?;
523        }
524        len += compact_array_length_len(self.state_changelog_topics.len() as i32);
525        for el in &self.state_changelog_topics {
526            len += el.encoded_len(version)?;
527        }
528        len += compact_array_length_len(self.repartition_source_topics.len() as i32);
529        for el in &self.repartition_source_topics {
530            len += el.encoded_len(version)?;
531        }
532        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
533        all_tags.sort_by_key(|f| f.tag);
534        len += tagged_fields_len(&all_tags)?;
535        Ok(len)
536    }
537}
538#[derive(Debug, Clone, PartialEq)]
539pub struct Member {
540    /// The member ID.
541    pub member_id: KafkaString,
542    /// The member epoch.
543    pub member_epoch: i32,
544    /// The member instance ID for static membership.
545    pub instance_id: Option<KafkaString>,
546    /// The rack ID.
547    pub rack_id: Option<KafkaString>,
548    /// The client ID.
549    pub client_id: KafkaString,
550    /// The client host.
551    pub client_host: KafkaString,
552    /// The epoch of the topology on the client.
553    pub topology_epoch: i32,
554    /// Identity of the streams instance that may have multiple clients.
555    pub process_id: KafkaString,
556    /// User-defined endpoint for Interactive Queries. Null if not defined for this client.
557    pub user_endpoint: Option<Box<Endpoint>>,
558    /// Used for rack-aware assignment algorithm.
559    pub client_tags: Vec<KeyValue>,
560    /// Cumulative changelog offsets for tasks.
561    pub task_offsets: Vec<TaskOffset>,
562    /// Cumulative changelog end offsets for tasks.
563    pub task_end_offsets: Vec<TaskOffset>,
564    /// The current assignment.
565    pub assignment: Assignment,
566    /// The target assignment.
567    pub target_assignment: Assignment,
568    /// True for classic members that have not been upgraded yet.
569    pub is_classic: bool,
570    pub _unknown_tagged_fields: Vec<RawTaggedField>,
571}
572impl Default for Member {
573    fn default() -> Self {
574        Self {
575            member_id: KafkaString::default(),
576            member_epoch: 0_i32,
577            instance_id: None,
578            rack_id: None,
579            client_id: KafkaString::default(),
580            client_host: KafkaString::default(),
581            topology_epoch: 0_i32,
582            process_id: KafkaString::default(),
583            user_endpoint: None,
584            client_tags: Vec::new(),
585            task_offsets: Vec::new(),
586            task_end_offsets: Vec::new(),
587            assignment: Assignment::default(),
588            target_assignment: Assignment::default(),
589            is_classic: false,
590            _unknown_tagged_fields: Vec::new(),
591        }
592    }
593}
594impl Member {
595    pub fn with_member_id(mut self, value: KafkaString) -> Self {
596        self.member_id = value;
597        self
598    }
599    pub fn with_member_epoch(mut self, value: i32) -> Self {
600        self.member_epoch = value;
601        self
602    }
603    pub fn with_instance_id(mut self, value: Option<KafkaString>) -> Self {
604        self.instance_id = value;
605        self
606    }
607    pub fn with_rack_id(mut self, value: Option<KafkaString>) -> Self {
608        self.rack_id = value;
609        self
610    }
611    pub fn with_client_id(mut self, value: KafkaString) -> Self {
612        self.client_id = value;
613        self
614    }
615    pub fn with_client_host(mut self, value: KafkaString) -> Self {
616        self.client_host = value;
617        self
618    }
619    pub fn with_topology_epoch(mut self, value: i32) -> Self {
620        self.topology_epoch = value;
621        self
622    }
623    pub fn with_process_id(mut self, value: KafkaString) -> Self {
624        self.process_id = value;
625        self
626    }
627    pub fn with_user_endpoint(mut self, value: Option<Box<Endpoint>>) -> Self {
628        self.user_endpoint = value;
629        self
630    }
631    pub fn with_client_tags(mut self, value: Vec<KeyValue>) -> Self {
632        self.client_tags = value;
633        self
634    }
635    pub fn with_task_offsets(mut self, value: Vec<TaskOffset>) -> Self {
636        self.task_offsets = value;
637        self
638    }
639    pub fn with_task_end_offsets(mut self, value: Vec<TaskOffset>) -> Self {
640        self.task_end_offsets = value;
641        self
642    }
643    pub fn with_assignment(mut self, value: Assignment) -> Self {
644        self.assignment = value;
645        self
646    }
647    pub fn with_target_assignment(mut self, value: Assignment) -> Self {
648        self.target_assignment = value;
649        self
650    }
651    pub fn with_is_classic(mut self, value: bool) -> Self {
652        self.is_classic = value;
653        self
654    }
655    pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
656        let member_id;
657        let member_epoch;
658        let instance_id;
659        let rack_id;
660        let client_id;
661        let client_host;
662        let topology_epoch;
663        let process_id;
664        let user_endpoint;
665        let client_tags;
666        let task_offsets;
667        let task_end_offsets;
668        let assignment;
669        let target_assignment;
670        let is_classic;
671        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
672        member_id = read_compact_string(buf)?;
673        member_epoch = read_i32(buf)?;
674        instance_id = read_compact_nullable_string(buf)?;
675        rack_id = read_compact_nullable_string(buf)?;
676        client_id = read_compact_string(buf)?;
677        client_host = read_compact_string(buf)?;
678        topology_epoch = read_i32(buf)?;
679        process_id = read_compact_string(buf)?;
680        user_endpoint = {
681            let marker = read_i8(buf)?;
682            if marker < 0 {
683                None
684            } else {
685                Some(Box::new(Endpoint::read(buf, version)?))
686            }
687        };
688        client_tags = {
689            let len = read_compact_array_length(buf)?;
690            let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
691            for _ in 0..len {
692                arr.push(KeyValue::read(buf, version)?);
693            }
694            arr
695        };
696        task_offsets = {
697            let len = read_compact_array_length(buf)?;
698            let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
699            for _ in 0..len {
700                arr.push(TaskOffset::read(buf, version)?);
701            }
702            arr
703        };
704        task_end_offsets = {
705            let len = read_compact_array_length(buf)?;
706            let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
707            for _ in 0..len {
708                arr.push(TaskOffset::read(buf, version)?);
709            }
710            arr
711        };
712        assignment = Assignment::read(buf, version)?;
713        target_assignment = Assignment::read(buf, version)?;
714        is_classic = read_bool(buf)?;
715        let tagged_fields = read_tagged_fields(buf)?;
716        for field in &tagged_fields {
717            match field.tag {
718                _ => {
719                    _unknown_tagged_fields.push(field.clone());
720                },
721            }
722        }
723        Ok(Self {
724            member_id,
725            member_epoch,
726            instance_id,
727            rack_id,
728            client_id,
729            client_host,
730            topology_epoch,
731            process_id,
732            user_endpoint,
733            client_tags,
734            task_offsets,
735            task_end_offsets,
736            assignment,
737            target_assignment,
738            is_classic,
739            _unknown_tagged_fields,
740        })
741    }
742    pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
743        write_compact_string(buf, &self.member_id)?;
744        write_i32(buf, self.member_epoch);
745        write_compact_nullable_string(buf, self.instance_id.as_ref())?;
746        write_compact_nullable_string(buf, self.rack_id.as_ref())?;
747        write_compact_string(buf, &self.client_id)?;
748        write_compact_string(buf, &self.client_host)?;
749        write_i32(buf, self.topology_epoch);
750        write_compact_string(buf, &self.process_id)?;
751        match &self.user_endpoint {
752            None => {
753                write_i8(buf, -1);
754            },
755            Some(v) => {
756                write_i8(buf, 1);
757                v.write(buf, version)?;
758            },
759        }
760        write_compact_array_length(buf, self.client_tags.len() as i32);
761        for el in &self.client_tags {
762            el.write(buf, version)?;
763        }
764        write_compact_array_length(buf, self.task_offsets.len() as i32);
765        for el in &self.task_offsets {
766            el.write(buf, version)?;
767        }
768        write_compact_array_length(buf, self.task_end_offsets.len() as i32);
769        for el in &self.task_end_offsets {
770            el.write(buf, version)?;
771        }
772        self.assignment.write(buf, version)?;
773        self.target_assignment.write(buf, version)?;
774        write_bool(buf, self.is_classic);
775        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
776        all_tags.sort_by_key(|f| f.tag);
777        write_tagged_fields(buf, &all_tags)?;
778        Ok(())
779    }
780    pub fn encoded_len(&self, version: i16) -> Result<usize> {
781        let mut len: usize = 0;
782        len += compact_string_len(&self.member_id)?;
783        len += 4;
784        len += compact_nullable_string_len(self.instance_id.as_ref())?;
785        len += compact_nullable_string_len(self.rack_id.as_ref())?;
786        len += compact_string_len(&self.client_id)?;
787        len += compact_string_len(&self.client_host)?;
788        len += 4;
789        len += compact_string_len(&self.process_id)?;
790        match &self.user_endpoint {
791            None => {
792                len += 1;
793            },
794            Some(v) => {
795                len += 1;
796                len += v.encoded_len(version)?;
797            },
798        }
799        len += compact_array_length_len(self.client_tags.len() as i32);
800        for el in &self.client_tags {
801            len += el.encoded_len(version)?;
802        }
803        len += compact_array_length_len(self.task_offsets.len() as i32);
804        for el in &self.task_offsets {
805            len += el.encoded_len(version)?;
806        }
807        len += compact_array_length_len(self.task_end_offsets.len() as i32);
808        for el in &self.task_end_offsets {
809            len += el.encoded_len(version)?;
810        }
811        len += self.assignment.encoded_len(version)?;
812        len += self.target_assignment.encoded_len(version)?;
813        len += 1;
814        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
815        all_tags.sort_by_key(|f| f.tag);
816        len += tagged_fields_len(&all_tags)?;
817        Ok(len)
818    }
819}
820#[derive(Debug, Clone, PartialEq)]
821pub struct Endpoint {
822    /// host of the endpoint
823    pub host: KafkaString,
824    /// port of the endpoint
825    pub port: u16,
826    pub _unknown_tagged_fields: Vec<RawTaggedField>,
827}
828impl Default for Endpoint {
829    fn default() -> Self {
830        Self {
831            host: KafkaString::default(),
832            port: 0_u16,
833            _unknown_tagged_fields: Vec::new(),
834        }
835    }
836}
837impl Endpoint {
838    pub fn with_host(mut self, value: KafkaString) -> Self {
839        self.host = value;
840        self
841    }
842    pub fn with_port(mut self, value: u16) -> Self {
843        self.port = value;
844        self
845    }
846    pub fn read(buf: &mut Bytes, _version: i16) -> Result<Self> {
847        let host;
848        let port;
849        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
850        host = read_compact_string(buf)?;
851        port = read_u16(buf)?;
852        let tagged_fields = read_tagged_fields(buf)?;
853        for field in &tagged_fields {
854            match field.tag {
855                _ => {
856                    _unknown_tagged_fields.push(field.clone());
857                },
858            }
859        }
860        Ok(Self {
861            host,
862            port,
863            _unknown_tagged_fields,
864        })
865    }
866    pub fn write(&self, buf: &mut BytesMut, _version: i16) -> Result<()> {
867        write_compact_string(buf, &self.host)?;
868        write_u16(buf, self.port);
869        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
870        all_tags.sort_by_key(|f| f.tag);
871        write_tagged_fields(buf, &all_tags)?;
872        Ok(())
873    }
874    pub fn encoded_len(&self, _version: i16) -> Result<usize> {
875        let mut len: usize = 0;
876        len += compact_string_len(&self.host)?;
877        len += 2;
878        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
879        all_tags.sort_by_key(|f| f.tag);
880        len += tagged_fields_len(&all_tags)?;
881        Ok(len)
882    }
883}
884#[derive(Debug, Clone, PartialEq)]
885pub struct TaskOffset {
886    /// The subtopology identifier.
887    pub subtopology_id: KafkaString,
888    /// The partition.
889    pub partition: i32,
890    /// The offset.
891    pub offset: i64,
892    pub _unknown_tagged_fields: Vec<RawTaggedField>,
893}
894impl Default for TaskOffset {
895    fn default() -> Self {
896        Self {
897            subtopology_id: KafkaString::default(),
898            partition: 0_i32,
899            offset: 0_i64,
900            _unknown_tagged_fields: Vec::new(),
901        }
902    }
903}
904impl TaskOffset {
905    pub fn with_subtopology_id(mut self, value: KafkaString) -> Self {
906        self.subtopology_id = value;
907        self
908    }
909    pub fn with_partition(mut self, value: i32) -> Self {
910        self.partition = value;
911        self
912    }
913    pub fn with_offset(mut self, value: i64) -> Self {
914        self.offset = value;
915        self
916    }
917    pub fn read(buf: &mut Bytes, _version: i16) -> Result<Self> {
918        let subtopology_id;
919        let partition;
920        let offset;
921        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
922        subtopology_id = read_compact_string(buf)?;
923        partition = read_i32(buf)?;
924        offset = read_i64(buf)?;
925        let tagged_fields = read_tagged_fields(buf)?;
926        for field in &tagged_fields {
927            match field.tag {
928                _ => {
929                    _unknown_tagged_fields.push(field.clone());
930                },
931            }
932        }
933        Ok(Self {
934            subtopology_id,
935            partition,
936            offset,
937            _unknown_tagged_fields,
938        })
939    }
940    pub fn write(&self, buf: &mut BytesMut, _version: i16) -> Result<()> {
941        write_compact_string(buf, &self.subtopology_id)?;
942        write_i32(buf, self.partition);
943        write_i64(buf, self.offset);
944        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
945        all_tags.sort_by_key(|f| f.tag);
946        write_tagged_fields(buf, &all_tags)?;
947        Ok(())
948    }
949    pub fn encoded_len(&self, _version: i16) -> Result<usize> {
950        let mut len: usize = 0;
951        len += compact_string_len(&self.subtopology_id)?;
952        len += 4;
953        len += 8;
954        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
955        all_tags.sort_by_key(|f| f.tag);
956        len += tagged_fields_len(&all_tags)?;
957        Ok(len)
958    }
959}
960#[derive(Debug, Clone, PartialEq)]
961pub struct Assignment {
962    /// Active tasks for this client.
963    pub active_tasks: Vec<TaskIds>,
964    /// Standby tasks for this client.
965    pub standby_tasks: Vec<TaskIds>,
966    /// Warm-up tasks for this client.
967    pub warmup_tasks: Vec<TaskIds>,
968    pub _unknown_tagged_fields: Vec<RawTaggedField>,
969}
970impl Default for Assignment {
971    fn default() -> Self {
972        Self {
973            active_tasks: Vec::new(),
974            standby_tasks: Vec::new(),
975            warmup_tasks: Vec::new(),
976            _unknown_tagged_fields: Vec::new(),
977        }
978    }
979}
980impl Assignment {
981    pub fn with_active_tasks(mut self, value: Vec<TaskIds>) -> Self {
982        self.active_tasks = value;
983        self
984    }
985    pub fn with_standby_tasks(mut self, value: Vec<TaskIds>) -> Self {
986        self.standby_tasks = value;
987        self
988    }
989    pub fn with_warmup_tasks(mut self, value: Vec<TaskIds>) -> Self {
990        self.warmup_tasks = value;
991        self
992    }
993    pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
994        let active_tasks;
995        let standby_tasks;
996        let warmup_tasks;
997        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
998        active_tasks = {
999            let len = read_compact_array_length(buf)?;
1000            let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
1001            for _ in 0..len {
1002                arr.push(TaskIds::read(buf, version)?);
1003            }
1004            arr
1005        };
1006        standby_tasks = {
1007            let len = read_compact_array_length(buf)?;
1008            let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
1009            for _ in 0..len {
1010                arr.push(TaskIds::read(buf, version)?);
1011            }
1012            arr
1013        };
1014        warmup_tasks = {
1015            let len = read_compact_array_length(buf)?;
1016            let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
1017            for _ in 0..len {
1018                arr.push(TaskIds::read(buf, version)?);
1019            }
1020            arr
1021        };
1022        let tagged_fields = read_tagged_fields(buf)?;
1023        for field in &tagged_fields {
1024            match field.tag {
1025                _ => {
1026                    _unknown_tagged_fields.push(field.clone());
1027                },
1028            }
1029        }
1030        Ok(Self {
1031            active_tasks,
1032            standby_tasks,
1033            warmup_tasks,
1034            _unknown_tagged_fields,
1035        })
1036    }
1037    pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
1038        write_compact_array_length(buf, self.active_tasks.len() as i32);
1039        for el in &self.active_tasks {
1040            el.write(buf, version)?;
1041        }
1042        write_compact_array_length(buf, self.standby_tasks.len() as i32);
1043        for el in &self.standby_tasks {
1044            el.write(buf, version)?;
1045        }
1046        write_compact_array_length(buf, self.warmup_tasks.len() as i32);
1047        for el in &self.warmup_tasks {
1048            el.write(buf, version)?;
1049        }
1050        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
1051        all_tags.sort_by_key(|f| f.tag);
1052        write_tagged_fields(buf, &all_tags)?;
1053        Ok(())
1054    }
1055    pub fn encoded_len(&self, version: i16) -> Result<usize> {
1056        let mut len: usize = 0;
1057        len += compact_array_length_len(self.active_tasks.len() as i32);
1058        for el in &self.active_tasks {
1059            len += el.encoded_len(version)?;
1060        }
1061        len += compact_array_length_len(self.standby_tasks.len() as i32);
1062        for el in &self.standby_tasks {
1063            len += el.encoded_len(version)?;
1064        }
1065        len += compact_array_length_len(self.warmup_tasks.len() as i32);
1066        for el in &self.warmup_tasks {
1067            len += el.encoded_len(version)?;
1068        }
1069        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
1070        all_tags.sort_by_key(|f| f.tag);
1071        len += tagged_fields_len(&all_tags)?;
1072        Ok(len)
1073    }
1074}
1075#[derive(Debug, Clone, PartialEq)]
1076pub struct TaskIds {
1077    /// The subtopology identifier.
1078    pub subtopology_id: KafkaString,
1079    /// The partitions of the input topics processed by this member.
1080    pub partitions: Vec<i32>,
1081    pub _unknown_tagged_fields: Vec<RawTaggedField>,
1082}
1083impl Default for TaskIds {
1084    fn default() -> Self {
1085        Self {
1086            subtopology_id: KafkaString::default(),
1087            partitions: Vec::new(),
1088            _unknown_tagged_fields: Vec::new(),
1089        }
1090    }
1091}
1092impl TaskIds {
1093    pub fn with_subtopology_id(mut self, value: KafkaString) -> Self {
1094        self.subtopology_id = value;
1095        self
1096    }
1097    pub fn with_partitions(mut self, value: Vec<i32>) -> Self {
1098        self.partitions = value;
1099        self
1100    }
1101    pub fn read(buf: &mut Bytes, _version: i16) -> Result<Self> {
1102        let subtopology_id;
1103        let partitions;
1104        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
1105        subtopology_id = read_compact_string(buf)?;
1106        partitions = {
1107            let len = read_compact_array_length(buf)?;
1108            let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
1109            for _ in 0..len {
1110                arr.push(read_i32(buf)?);
1111            }
1112            arr
1113        };
1114        let tagged_fields = read_tagged_fields(buf)?;
1115        for field in &tagged_fields {
1116            match field.tag {
1117                _ => {
1118                    _unknown_tagged_fields.push(field.clone());
1119                },
1120            }
1121        }
1122        Ok(Self {
1123            subtopology_id,
1124            partitions,
1125            _unknown_tagged_fields,
1126        })
1127    }
1128    pub fn write(&self, buf: &mut BytesMut, _version: i16) -> Result<()> {
1129        write_compact_string(buf, &self.subtopology_id)?;
1130        write_compact_array_length(buf, self.partitions.len() as i32);
1131        for el in &self.partitions {
1132            write_i32(buf, *el);
1133        }
1134        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
1135        all_tags.sort_by_key(|f| f.tag);
1136        write_tagged_fields(buf, &all_tags)?;
1137        Ok(())
1138    }
1139    pub fn encoded_len(&self, _version: i16) -> Result<usize> {
1140        let mut len: usize = 0;
1141        len += compact_string_len(&self.subtopology_id)?;
1142        len += compact_array_length_len(self.partitions.len() as i32);
1143        len += self.partitions.len() * 4usize;
1144        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
1145        all_tags.sort_by_key(|f| f.tag);
1146        len += tagged_fields_len(&all_tags)?;
1147        Ok(len)
1148    }
1149}
1150#[derive(Debug, Clone, PartialEq)]
1151pub struct KeyValue {
1152    /// key of the config
1153    pub key: KafkaString,
1154    /// value of the config
1155    pub value: KafkaString,
1156    pub _unknown_tagged_fields: Vec<RawTaggedField>,
1157}
1158impl Default for KeyValue {
1159    fn default() -> Self {
1160        Self {
1161            key: KafkaString::default(),
1162            value: KafkaString::default(),
1163            _unknown_tagged_fields: Vec::new(),
1164        }
1165    }
1166}
1167impl KeyValue {
1168    pub fn with_key(mut self, value: KafkaString) -> Self {
1169        self.key = value;
1170        self
1171    }
1172    pub fn with_value(mut self, value: KafkaString) -> Self {
1173        self.value = value;
1174        self
1175    }
1176    pub fn read(buf: &mut Bytes, _version: i16) -> Result<Self> {
1177        let key;
1178        let value;
1179        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
1180        key = read_compact_string(buf)?;
1181        value = read_compact_string(buf)?;
1182        let tagged_fields = read_tagged_fields(buf)?;
1183        for field in &tagged_fields {
1184            match field.tag {
1185                _ => {
1186                    _unknown_tagged_fields.push(field.clone());
1187                },
1188            }
1189        }
1190        Ok(Self {
1191            key,
1192            value,
1193            _unknown_tagged_fields,
1194        })
1195    }
1196    pub fn write(&self, buf: &mut BytesMut, _version: i16) -> Result<()> {
1197        write_compact_string(buf, &self.key)?;
1198        write_compact_string(buf, &self.value)?;
1199        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
1200        all_tags.sort_by_key(|f| f.tag);
1201        write_tagged_fields(buf, &all_tags)?;
1202        Ok(())
1203    }
1204    pub fn encoded_len(&self, _version: i16) -> Result<usize> {
1205        let mut len: usize = 0;
1206        len += compact_string_len(&self.key)?;
1207        len += compact_string_len(&self.value)?;
1208        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
1209        all_tags.sort_by_key(|f| f.tag);
1210        len += tagged_fields_len(&all_tags)?;
1211        Ok(len)
1212    }
1213}
1214#[derive(Debug, Clone, PartialEq)]
1215pub struct TopicInfo {
1216    /// The name of the topic.
1217    pub name: KafkaString,
1218    /// The number of partitions in the topic. Can be 0 if no specific number of partitions is
1219    /// enforced. Always 0 for changelog topics.
1220    pub partitions: i32,
1221    /// The replication factor of the topic. Can be 0 if the default replication factor should be
1222    /// used.
1223    pub replication_factor: i16,
1224    /// Topic-level configurations as key-value pairs.
1225    pub topic_configs: Vec<KeyValue>,
1226    pub _unknown_tagged_fields: Vec<RawTaggedField>,
1227}
1228impl Default for TopicInfo {
1229    fn default() -> Self {
1230        Self {
1231            name: KafkaString::default(),
1232            partitions: 0_i32,
1233            replication_factor: 0_i16,
1234            topic_configs: Vec::new(),
1235            _unknown_tagged_fields: Vec::new(),
1236        }
1237    }
1238}
1239impl TopicInfo {
1240    pub fn with_name(mut self, value: KafkaString) -> Self {
1241        self.name = value;
1242        self
1243    }
1244    pub fn with_partitions(mut self, value: i32) -> Self {
1245        self.partitions = value;
1246        self
1247    }
1248    pub fn with_replication_factor(mut self, value: i16) -> Self {
1249        self.replication_factor = value;
1250        self
1251    }
1252    pub fn with_topic_configs(mut self, value: Vec<KeyValue>) -> Self {
1253        self.topic_configs = value;
1254        self
1255    }
1256    pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
1257        let name;
1258        let partitions;
1259        let replication_factor;
1260        let topic_configs;
1261        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
1262        name = read_compact_string(buf)?;
1263        partitions = read_i32(buf)?;
1264        replication_factor = read_i16(buf)?;
1265        topic_configs = {
1266            let len = read_compact_array_length(buf)?;
1267            let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
1268            for _ in 0..len {
1269                arr.push(KeyValue::read(buf, version)?);
1270            }
1271            arr
1272        };
1273        let tagged_fields = read_tagged_fields(buf)?;
1274        for field in &tagged_fields {
1275            match field.tag {
1276                _ => {
1277                    _unknown_tagged_fields.push(field.clone());
1278                },
1279            }
1280        }
1281        Ok(Self {
1282            name,
1283            partitions,
1284            replication_factor,
1285            topic_configs,
1286            _unknown_tagged_fields,
1287        })
1288    }
1289    pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
1290        write_compact_string(buf, &self.name)?;
1291        write_i32(buf, self.partitions);
1292        write_i16(buf, self.replication_factor);
1293        write_compact_array_length(buf, self.topic_configs.len() as i32);
1294        for el in &self.topic_configs {
1295            el.write(buf, version)?;
1296        }
1297        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
1298        all_tags.sort_by_key(|f| f.tag);
1299        write_tagged_fields(buf, &all_tags)?;
1300        Ok(())
1301    }
1302    pub fn encoded_len(&self, version: i16) -> Result<usize> {
1303        let mut len: usize = 0;
1304        len += compact_string_len(&self.name)?;
1305        len += 4;
1306        len += 2;
1307        len += compact_array_length_len(self.topic_configs.len() as i32);
1308        for el in &self.topic_configs {
1309            len += el.encoded_len(version)?;
1310        }
1311        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
1312        all_tags.sort_by_key(|f| f.tag);
1313        len += tagged_fields_len(&all_tags)?;
1314        Ok(len)
1315    }
1316}