Skip to main content

krabka_protocol/opt/rustwide/workdir/generated/
StreamsGroupHeartbeatResponse.borrowed.rs

1// AUTO-GENERATED by krabka-protocol-codegen against a9ce3221537b8653448750697915607dc7936cf3. Do not edit.
2use bytes::BufMut;
3
4use crate::{
5    DecodeBorrow, Encode, ProtocolError, UnknownTaggedFields,
6    primitives::{
7        fixed::{get_bool, get_i16, get_i32, get_i64, put_bool, put_i16, put_i32, put_i64},
8        string_bytes::{
9            compact_nullable_string_len, compact_string_len, nullable_string_len,
10            put_compact_nullable_string, put_compact_string, put_nullable_string, put_string,
11            string_len,
12        },
13        string_bytes_borrowed::{
14            get_compact_nullable_string_borrowed, get_compact_string_borrowed,
15            get_nullable_string_borrowed, get_string_borrowed,
16        },
17    },
18    tagged_fields::{WriteTaggedFields, read_tagged_fields, tagged_fields_len},
19};
20pub const API_KEY: i16 = 88;
21pub const MIN_VERSION: i16 = 0;
22pub const MAX_VERSION: i16 = 1;
23pub const FLEXIBLE_MIN: i16 = 0;
24#[inline]
25#[must_use]
26pub fn is_flexible(version: i16) -> bool {
27    version >= FLEXIBLE_MIN
28}
29#[derive(Debug, Clone, PartialEq, Eq)]
30pub struct StreamsGroupHeartbeatResponse<'a> {
31    pub throttle_time_ms: i32,
32    pub error_code: i16,
33    pub error_message: Option<&'a str>,
34    pub member_id: &'a str,
35    pub member_epoch: i32,
36    pub heartbeat_interval_ms: i32,
37    pub acceptable_recovery_lag_legacy: i32,
38    pub task_offset_interval_ms: i32,
39    pub acceptable_recovery_lag: i64,
40    pub status: Option<Vec<super::common::streams_group_heartbeat_response::status::Status<'a>>>,
41    pub active_tasks:
42        Option<Vec<super::common::streams_group_heartbeat_response::task_ids::TaskIds<'a>>>,
43    pub standby_tasks:
44        Option<Vec<super::common::streams_group_heartbeat_response::task_ids::TaskIds<'a>>>,
45    pub warmup_tasks:
46        Option<Vec<super::common::streams_group_heartbeat_response::task_ids::TaskIds<'a>>>,
47    pub topology_description_required: bool,
48    pub endpoint_information_epoch: i32,
49    pub partitions_by_user_endpoint: Option<Vec<EndpointToPartitions<'a>>>,
50    pub unknown_tagged_fields: UnknownTaggedFields,
51}
52impl Default for StreamsGroupHeartbeatResponse<'_> {
53    fn default() -> Self {
54        Self {
55            throttle_time_ms: 0i32,
56            error_code: 0i16,
57            error_message: None,
58            member_id: "",
59            member_epoch: 0i32,
60            heartbeat_interval_ms: 0i32,
61            acceptable_recovery_lag_legacy: 0i32,
62            task_offset_interval_ms: 0i32,
63            acceptable_recovery_lag: -1i64,
64            status: Some(Vec::new()),
65            active_tasks: None,
66            standby_tasks: None,
67            warmup_tasks: None,
68            topology_description_required: false,
69            endpoint_information_epoch: 0i32,
70            partitions_by_user_endpoint: None,
71            unknown_tagged_fields: UnknownTaggedFields::default(),
72        }
73    }
74}
75impl<'a> StreamsGroupHeartbeatResponse<'a> {
76    /// # Panics
77    ///
78    /// Panics if a records field contains an invalid encoded record batch.
79    #[must_use]
80    pub fn to_owned(
81        &self,
82    ) -> crate::owned::streams_group_heartbeat_response::StreamsGroupHeartbeatResponse {
83        crate::owned::streams_group_heartbeat_response::StreamsGroupHeartbeatResponse {
84            throttle_time_ms: (self.throttle_time_ms),
85            error_code: (self.error_code),
86            error_message: (self.error_message).map(std::string::ToString::to_string),
87            member_id: (self.member_id).to_string(),
88            member_epoch: (self.member_epoch),
89            heartbeat_interval_ms: (self.heartbeat_interval_ms),
90            acceptable_recovery_lag_legacy: (self.acceptable_recovery_lag_legacy),
91            task_offset_interval_ms: (self.task_offset_interval_ms),
92            acceptable_recovery_lag: (self.acceptable_recovery_lag),
93            status: (self.status).as_ref().map(|v| v.iter().map(super::common::streams_group_heartbeat_response::status::Status::to_owned).collect()),
94            active_tasks: (self.active_tasks).as_ref().map(|v| v.iter().map(super::common::streams_group_heartbeat_response::task_ids::TaskIds::to_owned).collect()),
95            standby_tasks: (self.standby_tasks).as_ref().map(|v| v.iter().map(super::common::streams_group_heartbeat_response::task_ids::TaskIds::to_owned).collect()),
96            warmup_tasks: (self.warmup_tasks).as_ref().map(|v| v.iter().map(super::common::streams_group_heartbeat_response::task_ids::TaskIds::to_owned).collect()),
97            topology_description_required: (self.topology_description_required),
98            endpoint_information_epoch: (self.endpoint_information_epoch),
99            partitions_by_user_endpoint: (self.partitions_by_user_endpoint).as_ref().map(|v| v.iter().map(EndpointToPartitions::to_owned).collect()),
100            unknown_tagged_fields: self.unknown_tagged_fields.clone(),
101        }
102    }
103    fn encode_field_0<B: BufMut>(&self, buf: &mut B, version: i16, _flex: bool) {
104        if version >= 0 {
105            put_i32(buf, self.throttle_time_ms);
106        }
107    }
108    fn encode_field_1<B: BufMut>(&self, buf: &mut B, version: i16, _flex: bool) {
109        if version >= 0 {
110            put_i16(buf, self.error_code);
111        }
112    }
113    fn encode_field_2<B: BufMut>(&self, buf: &mut B, version: i16, flex: bool) {
114        if version >= 0 {
115            if flex {
116                let () = put_compact_nullable_string(buf, self.error_message);
117            } else {
118                let () = put_nullable_string(buf, self.error_message);
119            }
120        }
121    }
122    fn encode_field_3<B: BufMut>(&self, buf: &mut B, version: i16, flex: bool) {
123        if version >= 0 {
124            if flex {
125                let () = put_compact_string(buf, self.member_id);
126            } else {
127                let () = put_string(buf, self.member_id);
128            }
129        }
130    }
131    fn encode_field_4<B: BufMut>(&self, buf: &mut B, version: i16, _flex: bool) {
132        if version >= 0 {
133            put_i32(buf, self.member_epoch);
134        }
135    }
136    fn encode_field_5<B: BufMut>(&self, buf: &mut B, version: i16, _flex: bool) {
137        if version >= 0 {
138            put_i32(buf, self.heartbeat_interval_ms);
139        }
140    }
141    fn encode_field_6<B: BufMut>(&self, buf: &mut B, version: i16, _flex: bool) {
142        if version == 0 {
143            put_i32(buf, self.acceptable_recovery_lag_legacy);
144        }
145    }
146    fn encode_field_7<B: BufMut>(&self, buf: &mut B, version: i16, _flex: bool) {
147        if version >= 0 {
148            put_i32(buf, self.task_offset_interval_ms);
149        }
150    }
151    fn encode_field_8<B: BufMut>(&self, buf: &mut B, version: i16, _flex: bool) {
152        if version >= 1 {
153            put_i64(buf, self.acceptable_recovery_lag);
154        }
155    }
156    fn encode_field_9<B: BufMut>(
157        &self,
158        buf: &mut B,
159        version: i16,
160        flex: bool,
161    ) -> Result<(), ProtocolError> {
162        if version >= 0 {
163            {
164                let len = (self.status).as_ref().map(Vec::len);
165                crate::primitives::array::put_nullable_array_len(buf, len, flex);
166                if let Some(v) = &self.status {
167                    for it in v {
168                        it.encode(buf, version)?;
169                    }
170                }
171            };
172        }
173        Ok(())
174    }
175    fn encode_field_10<B: BufMut>(
176        &self,
177        buf: &mut B,
178        version: i16,
179        flex: bool,
180    ) -> Result<(), ProtocolError> {
181        if version >= 0 {
182            {
183                let len = (self.active_tasks).as_ref().map(Vec::len);
184                crate::primitives::array::put_nullable_array_len(buf, len, flex);
185                if let Some(v) = &self.active_tasks {
186                    for it in v {
187                        it.encode(buf, version)?;
188                    }
189                }
190            };
191        }
192        Ok(())
193    }
194    fn encode_field_11<B: BufMut>(
195        &self,
196        buf: &mut B,
197        version: i16,
198        flex: bool,
199    ) -> Result<(), ProtocolError> {
200        if version >= 0 {
201            {
202                let len = (self.standby_tasks).as_ref().map(Vec::len);
203                crate::primitives::array::put_nullable_array_len(buf, len, flex);
204                if let Some(v) = &self.standby_tasks {
205                    for it in v {
206                        it.encode(buf, version)?;
207                    }
208                }
209            };
210        }
211        Ok(())
212    }
213    fn encode_field_12<B: BufMut>(
214        &self,
215        buf: &mut B,
216        version: i16,
217        flex: bool,
218    ) -> Result<(), ProtocolError> {
219        if version >= 0 {
220            {
221                let len = (self.warmup_tasks).as_ref().map(Vec::len);
222                crate::primitives::array::put_nullable_array_len(buf, len, flex);
223                if let Some(v) = &self.warmup_tasks {
224                    for it in v {
225                        it.encode(buf, version)?;
226                    }
227                }
228            };
229        }
230        Ok(())
231    }
232    fn encode_field_13<B: BufMut>(&self, buf: &mut B, version: i16, _flex: bool) {
233        if version >= 1 {
234            put_bool(buf, self.topology_description_required);
235        }
236    }
237    fn encode_field_14<B: BufMut>(&self, buf: &mut B, version: i16, _flex: bool) {
238        if version >= 0 {
239            put_i32(buf, self.endpoint_information_epoch);
240        }
241    }
242    fn encode_field_15<B: BufMut>(
243        &self,
244        buf: &mut B,
245        version: i16,
246        flex: bool,
247    ) -> Result<(), ProtocolError> {
248        if version >= 0 {
249            {
250                let len = (self.partitions_by_user_endpoint).as_ref().map(Vec::len);
251                crate::primitives::array::put_nullable_array_len(buf, len, flex);
252                if let Some(v) = &self.partitions_by_user_endpoint {
253                    for it in v {
254                        it.encode(buf, version)?;
255                    }
256                }
257            };
258        }
259        Ok(())
260    }
261    fn encode_tagged_fields<B: BufMut>(&self, buf: &mut B, _version: i16, flex: bool) {
262        if flex {
263            let tagged = WriteTaggedFields::new();
264            tagged.write(buf, &self.unknown_tagged_fields);
265        }
266    }
267    fn decode_field_0(
268        out: &mut Self,
269        buf: &mut &'a [u8],
270        version: i16,
271        _flex: bool,
272    ) -> Result<(), ProtocolError> {
273        if version >= 0 {
274            out.throttle_time_ms = get_i32(buf)?;
275        }
276        Ok(())
277    }
278    fn decode_field_1(
279        out: &mut Self,
280        buf: &mut &'a [u8],
281        version: i16,
282        _flex: bool,
283    ) -> Result<(), ProtocolError> {
284        if version >= 0 {
285            out.error_code = get_i16(buf)?;
286        }
287        Ok(())
288    }
289    fn decode_field_2(
290        out: &mut Self,
291        buf: &mut &'a [u8],
292        version: i16,
293        flex: bool,
294    ) -> Result<(), ProtocolError> {
295        if version >= 0 {
296            out.error_message = if flex {
297                get_compact_nullable_string_borrowed(buf)?
298            } else {
299                get_nullable_string_borrowed(buf)?
300            };
301        }
302        Ok(())
303    }
304    fn decode_field_3(
305        out: &mut Self,
306        buf: &mut &'a [u8],
307        version: i16,
308        flex: bool,
309    ) -> Result<(), ProtocolError> {
310        if version >= 0 {
311            out.member_id = if flex {
312                get_compact_string_borrowed(buf)?
313            } else {
314                get_string_borrowed(buf)?
315            };
316        }
317        Ok(())
318    }
319    fn decode_field_4(
320        out: &mut Self,
321        buf: &mut &'a [u8],
322        version: i16,
323        _flex: bool,
324    ) -> Result<(), ProtocolError> {
325        if version >= 0 {
326            out.member_epoch = get_i32(buf)?;
327        }
328        Ok(())
329    }
330    fn decode_field_5(
331        out: &mut Self,
332        buf: &mut &'a [u8],
333        version: i16,
334        _flex: bool,
335    ) -> Result<(), ProtocolError> {
336        if version >= 0 {
337            out.heartbeat_interval_ms = get_i32(buf)?;
338        }
339        Ok(())
340    }
341    fn decode_field_6(
342        out: &mut Self,
343        buf: &mut &'a [u8],
344        version: i16,
345        _flex: bool,
346    ) -> Result<(), ProtocolError> {
347        if version == 0 {
348            out.acceptable_recovery_lag_legacy = get_i32(buf)?;
349        }
350        Ok(())
351    }
352    fn decode_field_7(
353        out: &mut Self,
354        buf: &mut &'a [u8],
355        version: i16,
356        _flex: bool,
357    ) -> Result<(), ProtocolError> {
358        if version >= 0 {
359            out.task_offset_interval_ms = get_i32(buf)?;
360        }
361        Ok(())
362    }
363    fn decode_field_8(
364        out: &mut Self,
365        buf: &mut &'a [u8],
366        version: i16,
367        _flex: bool,
368    ) -> Result<(), ProtocolError> {
369        if version >= 1 {
370            out.acceptable_recovery_lag = get_i64(buf)?;
371        }
372        Ok(())
373    }
374    fn decode_field_9(
375        out: &mut Self,
376        buf: &mut &'a [u8],
377        version: i16,
378        flex: bool,
379    ) -> Result<(), ProtocolError> {
380        if version >= 0 {
381            out.status = {
382                let opt = crate::primitives::array::get_nullable_array_len(buf, flex)?;
383                match opt {
384                    None => None,
385                    Some(n) => {
386                        let mut v = Vec::with_capacity(n);
387                        for _ in 0..n {
388                            v.push(super::common::streams_group_heartbeat_response::status::Status::decode_borrow(buf, version)?);
389                        }
390                        Some(v)
391                    }
392                }
393            };
394        }
395        Ok(())
396    }
397    fn decode_field_10(
398        out: &mut Self,
399        buf: &mut &'a [u8],
400        version: i16,
401        flex: bool,
402    ) -> Result<(), ProtocolError> {
403        if version >= 0 {
404            out.active_tasks = {
405                let opt = crate::primitives::array::get_nullable_array_len(buf, flex)?;
406                match opt {
407                    None => None,
408                    Some(n) => {
409                        let mut v = Vec::with_capacity(n);
410                        for _ in 0..n {
411                            v.push(super::common::streams_group_heartbeat_response::task_ids::TaskIds::decode_borrow(buf, version)?);
412                        }
413                        Some(v)
414                    }
415                }
416            };
417        }
418        Ok(())
419    }
420    fn decode_field_11(
421        out: &mut Self,
422        buf: &mut &'a [u8],
423        version: i16,
424        flex: bool,
425    ) -> Result<(), ProtocolError> {
426        if version >= 0 {
427            out.standby_tasks = {
428                let opt = crate::primitives::array::get_nullable_array_len(buf, flex)?;
429                match opt {
430                    None => None,
431                    Some(n) => {
432                        let mut v = Vec::with_capacity(n);
433                        for _ in 0..n {
434                            v.push(super::common::streams_group_heartbeat_response::task_ids::TaskIds::decode_borrow(buf, version)?);
435                        }
436                        Some(v)
437                    }
438                }
439            };
440        }
441        Ok(())
442    }
443    fn decode_field_12(
444        out: &mut Self,
445        buf: &mut &'a [u8],
446        version: i16,
447        flex: bool,
448    ) -> Result<(), ProtocolError> {
449        if version >= 0 {
450            out.warmup_tasks = {
451                let opt = crate::primitives::array::get_nullable_array_len(buf, flex)?;
452                match opt {
453                    None => None,
454                    Some(n) => {
455                        let mut v = Vec::with_capacity(n);
456                        for _ in 0..n {
457                            v.push(super::common::streams_group_heartbeat_response::task_ids::TaskIds::decode_borrow(buf, version)?);
458                        }
459                        Some(v)
460                    }
461                }
462            };
463        }
464        Ok(())
465    }
466    fn decode_field_13(
467        out: &mut Self,
468        buf: &mut &'a [u8],
469        version: i16,
470        _flex: bool,
471    ) -> Result<(), ProtocolError> {
472        if version >= 1 {
473            out.topology_description_required = get_bool(buf)?;
474        }
475        Ok(())
476    }
477    fn decode_field_14(
478        out: &mut Self,
479        buf: &mut &'a [u8],
480        version: i16,
481        _flex: bool,
482    ) -> Result<(), ProtocolError> {
483        if version >= 0 {
484            out.endpoint_information_epoch = get_i32(buf)?;
485        }
486        Ok(())
487    }
488    fn decode_field_15(
489        out: &mut Self,
490        buf: &mut &'a [u8],
491        version: i16,
492        flex: bool,
493    ) -> Result<(), ProtocolError> {
494        if version >= 0 {
495            out.partitions_by_user_endpoint = {
496                let opt = crate::primitives::array::get_nullable_array_len(buf, flex)?;
497                match opt {
498                    None => None,
499                    Some(n) => {
500                        let mut v = Vec::with_capacity(n);
501                        for _ in 0..n {
502                            v.push(EndpointToPartitions::decode_borrow(buf, version)?);
503                        }
504                        Some(v)
505                    }
506                }
507            };
508        }
509        Ok(())
510    }
511    fn decode_tagged_fields(
512        out: &mut Self,
513        buf: &mut &'a [u8],
514        _version: i16,
515        flex: bool,
516    ) -> Result<(), ProtocolError> {
517        if flex {
518            out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
519        }
520        Ok(())
521    }
522}
523impl Encode for StreamsGroupHeartbeatResponse<'_> {
524    fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
525        if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
526            return Err(ProtocolError::UnsupportedVersion {
527                api_key: API_KEY,
528                version,
529            });
530        }
531        let flex = is_flexible(version);
532        self.encode_field_0(buf, version, flex);
533        self.encode_field_1(buf, version, flex);
534        self.encode_field_2(buf, version, flex);
535        self.encode_field_3(buf, version, flex);
536        self.encode_field_4(buf, version, flex);
537        self.encode_field_5(buf, version, flex);
538        self.encode_field_6(buf, version, flex);
539        self.encode_field_7(buf, version, flex);
540        self.encode_field_8(buf, version, flex);
541        self.encode_field_9(buf, version, flex)?;
542        self.encode_field_10(buf, version, flex)?;
543        self.encode_field_11(buf, version, flex)?;
544        self.encode_field_12(buf, version, flex)?;
545        self.encode_field_13(buf, version, flex);
546        self.encode_field_14(buf, version, flex);
547        self.encode_field_15(buf, version, flex)?;
548        self.encode_tagged_fields(buf, version, flex);
549        Ok(())
550    }
551    fn encoded_len(&self, version: i16) -> usize {
552        let flex = is_flexible(version);
553        let mut n: usize = 0;
554        if version >= 0 {
555            n += 4;
556        }
557        if version >= 0 {
558            n += 2;
559        }
560        if version >= 0 {
561            n += if flex {
562                compact_nullable_string_len(self.error_message)
563            } else {
564                nullable_string_len(self.error_message)
565            };
566        }
567        if version >= 0 {
568            n += if flex {
569                compact_string_len(self.member_id)
570            } else {
571                string_len(self.member_id)
572            };
573        }
574        if version >= 0 {
575            n += 4;
576        }
577        if version >= 0 {
578            n += 4;
579        }
580        if version == 0 {
581            n += 4;
582        }
583        if version >= 0 {
584            n += 4;
585        }
586        if version >= 1 {
587            n += 8;
588        }
589        if version >= 0 {
590            n += {
591                let opt: Option<&Vec<_>> = (self.status).as_ref();
592                let prefix = crate::primitives::array::nullable_array_len_prefix_len(
593                    opt.map(std::vec::Vec::len),
594                    flex,
595                );
596                let body: usize =
597                    opt.map_or(0, |v| v.iter().map(|it| it.encoded_len(version)).sum());
598                prefix + body
599            };
600        }
601        if version >= 0 {
602            n += {
603                let opt: Option<&Vec<_>> = (self.active_tasks).as_ref();
604                let prefix = crate::primitives::array::nullable_array_len_prefix_len(
605                    opt.map(std::vec::Vec::len),
606                    flex,
607                );
608                let body: usize =
609                    opt.map_or(0, |v| v.iter().map(|it| it.encoded_len(version)).sum());
610                prefix + body
611            };
612        }
613        if version >= 0 {
614            n += {
615                let opt: Option<&Vec<_>> = (self.standby_tasks).as_ref();
616                let prefix = crate::primitives::array::nullable_array_len_prefix_len(
617                    opt.map(std::vec::Vec::len),
618                    flex,
619                );
620                let body: usize =
621                    opt.map_or(0, |v| v.iter().map(|it| it.encoded_len(version)).sum());
622                prefix + body
623            };
624        }
625        if version >= 0 {
626            n += {
627                let opt: Option<&Vec<_>> = (self.warmup_tasks).as_ref();
628                let prefix = crate::primitives::array::nullable_array_len_prefix_len(
629                    opt.map(std::vec::Vec::len),
630                    flex,
631                );
632                let body: usize =
633                    opt.map_or(0, |v| v.iter().map(|it| it.encoded_len(version)).sum());
634                prefix + body
635            };
636        }
637        if version >= 1 {
638            n += 1;
639        }
640        if version >= 0 {
641            n += 4;
642        }
643        if version >= 0 {
644            n += {
645                let opt: Option<&Vec<_>> = (self.partitions_by_user_endpoint).as_ref();
646                let prefix = crate::primitives::array::nullable_array_len_prefix_len(
647                    opt.map(std::vec::Vec::len),
648                    flex,
649                );
650                let body: usize =
651                    opt.map_or(0, |v| v.iter().map(|it| it.encoded_len(version)).sum());
652                prefix + body
653            };
654        }
655        if flex {
656            let known_pairs: Vec<(u32, usize)> = Vec::new();
657            n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
658        }
659        n
660    }
661}
662impl<'de> DecodeBorrow<'de> for StreamsGroupHeartbeatResponse<'de> {
663    fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
664        if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
665            return Err(ProtocolError::UnsupportedVersion {
666                api_key: API_KEY,
667                version,
668            });
669        }
670        let flex = is_flexible(version);
671        let mut out = Self::default();
672        Self::decode_field_0(&mut out, buf, version, flex)?;
673        Self::decode_field_1(&mut out, buf, version, flex)?;
674        Self::decode_field_2(&mut out, buf, version, flex)?;
675        Self::decode_field_3(&mut out, buf, version, flex)?;
676        Self::decode_field_4(&mut out, buf, version, flex)?;
677        Self::decode_field_5(&mut out, buf, version, flex)?;
678        Self::decode_field_6(&mut out, buf, version, flex)?;
679        Self::decode_field_7(&mut out, buf, version, flex)?;
680        Self::decode_field_8(&mut out, buf, version, flex)?;
681        Self::decode_field_9(&mut out, buf, version, flex)?;
682        Self::decode_field_10(&mut out, buf, version, flex)?;
683        Self::decode_field_11(&mut out, buf, version, flex)?;
684        Self::decode_field_12(&mut out, buf, version, flex)?;
685        Self::decode_field_13(&mut out, buf, version, flex)?;
686        Self::decode_field_14(&mut out, buf, version, flex)?;
687        Self::decode_field_15(&mut out, buf, version, flex)?;
688        Self::decode_tagged_fields(&mut out, buf, version, flex)?;
689        Ok(out)
690    }
691}
692#[cfg(test)]
693impl StreamsGroupHeartbeatResponse<'_> {
694    #[must_use]
695    pub fn populated(version: i16) -> Self {
696        let mut m = Self::default();
697        if version >= 0 {
698            m.throttle_time_ms = 1i32;
699        }
700        if version >= 0 {
701            m.error_code = 1i16;
702        }
703        if version >= 0 {
704            m.error_message = Some("x");
705        }
706        if version >= 0 {
707            m.member_id = "x";
708        }
709        if version >= 0 {
710            m.member_epoch = 1i32;
711        }
712        if version >= 0 {
713            m.heartbeat_interval_ms = 1i32;
714        }
715        if version == 0 {
716            m.acceptable_recovery_lag_legacy = 1i32;
717        }
718        if version >= 0 {
719            m.task_offset_interval_ms = 1i32;
720        }
721        if version >= 1 {
722            m.acceptable_recovery_lag = 1i64;
723        }
724        if version >= 0 {
725            m.status = Some(vec![
726                super::common::streams_group_heartbeat_response::status::Status::populated(version),
727            ]);
728        }
729        if version >= 0 {
730            m.active_tasks = Some(vec![
731                super::common::streams_group_heartbeat_response::task_ids::TaskIds::populated(
732                    version,
733                ),
734            ]);
735        }
736        if version >= 0 {
737            m.standby_tasks = Some(vec![
738                super::common::streams_group_heartbeat_response::task_ids::TaskIds::populated(
739                    version,
740                ),
741            ]);
742        }
743        if version >= 0 {
744            m.warmup_tasks = Some(vec![
745                super::common::streams_group_heartbeat_response::task_ids::TaskIds::populated(
746                    version,
747                ),
748            ]);
749        }
750        if version >= 1 {
751            m.topology_description_required = true;
752        }
753        if version >= 0 {
754            m.endpoint_information_epoch = 1i32;
755        }
756        if version >= 0 {
757            m.partitions_by_user_endpoint = Some(vec![EndpointToPartitions::populated(version)]);
758        }
759        m
760    }
761}
762#[derive(Debug, Clone, PartialEq, Eq, Default)]
763pub struct EndpointToPartitions<'a> {
764    pub user_endpoint: super::common::streams_group_heartbeat_response::endpoint::Endpoint<'a>,
765    pub active_partitions:
766        Vec<super::common::streams_group_heartbeat_response::topic_partition::TopicPartition<'a>>,
767    pub standby_partitions:
768        Vec<super::common::streams_group_heartbeat_response::topic_partition::TopicPartition<'a>>,
769    pub unknown_tagged_fields: UnknownTaggedFields,
770}
771impl EndpointToPartitions<'_> {
772    /// # Panics
773    ///
774    /// Panics if a records field contains an invalid encoded record batch.
775    #[must_use]
776    pub fn to_owned(&self) -> crate::owned::streams_group_heartbeat_response::EndpointToPartitions {
777        crate::owned::streams_group_heartbeat_response::EndpointToPartitions {
778            user_endpoint: (self.user_endpoint).to_owned(),
779            active_partitions: (self.active_partitions).iter().map(super::common::streams_group_heartbeat_response::topic_partition::TopicPartition::to_owned).collect(),
780            standby_partitions: (self.standby_partitions).iter().map(super::common::streams_group_heartbeat_response::topic_partition::TopicPartition::to_owned).collect(),
781            unknown_tagged_fields: self.unknown_tagged_fields.clone(),
782        }
783    }
784}
785impl Encode for EndpointToPartitions<'_> {
786    fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
787        let flex = version >= 0;
788        if version >= 0 {
789            self.user_endpoint.encode(buf, version)?;
790        }
791        if version >= 0 {
792            {
793                crate::primitives::array::put_array_len(buf, (self.active_partitions).len(), flex);
794                for it in &self.active_partitions {
795                    it.encode(buf, version)?;
796                }
797            };
798        }
799        if version >= 0 {
800            {
801                crate::primitives::array::put_array_len(buf, (self.standby_partitions).len(), flex);
802                for it in &self.standby_partitions {
803                    it.encode(buf, version)?;
804                }
805            };
806        }
807        if flex {
808            let tagged = WriteTaggedFields::new();
809            tagged.write(buf, &self.unknown_tagged_fields);
810        }
811        Ok(())
812    }
813    fn encoded_len(&self, version: i16) -> usize {
814        let flex = version >= 0;
815        let mut n: usize = 0;
816        if version >= 0 {
817            n += self.user_endpoint.encoded_len(version);
818        }
819        if version >= 0 {
820            n += {
821                let prefix = crate::primitives::array::array_len_prefix_len(
822                    (self.active_partitions).len(),
823                    flex,
824                );
825                let body: usize = (self.active_partitions)
826                    .iter()
827                    .map(|it| it.encoded_len(version))
828                    .sum();
829                prefix + body
830            };
831        }
832        if version >= 0 {
833            n += {
834                let prefix = crate::primitives::array::array_len_prefix_len(
835                    (self.standby_partitions).len(),
836                    flex,
837                );
838                let body: usize = (self.standby_partitions)
839                    .iter()
840                    .map(|it| it.encoded_len(version))
841                    .sum();
842                prefix + body
843            };
844        }
845        if flex {
846            let known_pairs: Vec<(u32, usize)> = Vec::new();
847            n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
848        }
849        n
850    }
851}
852impl<'de> DecodeBorrow<'de> for EndpointToPartitions<'de> {
853    fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
854        let flex = version >= 0;
855        let mut out = Self::default();
856        if version >= 0 {
857            out.user_endpoint =
858                super::common::streams_group_heartbeat_response::endpoint::Endpoint::decode_borrow(
859                    buf, version,
860                )?;
861        }
862        if version >= 0 {
863            out.active_partitions = {
864                let n = crate::primitives::array::get_array_len(buf, flex)?;
865                let mut v = Vec::with_capacity(n);
866                for _ in 0..n {
867                    v.push(super::common::streams_group_heartbeat_response::topic_partition::TopicPartition::decode_borrow(buf, version)?);
868                }
869                v
870            };
871        }
872        if version >= 0 {
873            out.standby_partitions = {
874                let n = crate::primitives::array::get_array_len(buf, flex)?;
875                let mut v = Vec::with_capacity(n);
876                for _ in 0..n {
877                    v.push(super::common::streams_group_heartbeat_response::topic_partition::TopicPartition::decode_borrow(buf, version)?);
878                }
879                v
880            };
881        }
882        if flex {
883            out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
884        }
885        Ok(out)
886    }
887}
888#[cfg(test)]
889impl EndpointToPartitions<'_> {
890    #[must_use]
891    pub fn populated(version: i16) -> Self {
892        let mut m = Self::default();
893        if version >= 0 {
894            m.user_endpoint =
895                super::common::streams_group_heartbeat_response::endpoint::Endpoint::populated(
896                    version,
897                );
898        }
899        if version >= 0 {
900            m.active_partitions = vec![super::common::streams_group_heartbeat_response::topic_partition::TopicPartition::populated(version)];
901        }
902        if version >= 0 {
903            m.standby_partitions = vec![super::common::streams_group_heartbeat_response::topic_partition::TopicPartition::populated(version)];
904        }
905        m
906    }
907}