Skip to main content

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

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