Skip to main content

kacrab_protocol/generated/
streams_group_heartbeat_request.rs

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