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