1use bytes::BufMut;
3
4use crate::{
5 DecodeBorrow, Encode, ProtocolError, UnknownTaggedFields,
6 primitives::{
7 fixed::{get_bool, get_i8, get_i16, get_i32, put_bool, put_i16, put_i32},
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 LATEST_STABLE_VERSION: i16 = 1;
24pub const FLEXIBLE_MIN: i16 = 0;
25#[inline]
26#[must_use]
27pub fn is_flexible(version: i16) -> bool {
28 version >= FLEXIBLE_MIN
29}
30#[derive(Debug, Clone, PartialEq, Eq)]
31pub struct StreamsGroupHeartbeatRequest<'a> {
32 pub group_id: &'a str,
33 pub member_id: &'a str,
34 pub member_epoch: i32,
35 pub endpoint_information_epoch: i32,
36 pub instance_id: Option<&'a str>,
37 pub rack_id: Option<&'a str>,
38 pub rebalance_timeout_ms: i32,
39 pub topology: Option<Topology<'a>>,
40 pub active_tasks:
41 Option<Vec<super::common::streams_group_heartbeat_request::task_ids::TaskIds<'a>>>,
42 pub standby_tasks:
43 Option<Vec<super::common::streams_group_heartbeat_request::task_ids::TaskIds<'a>>>,
44 pub warmup_tasks:
45 Option<Vec<super::common::streams_group_heartbeat_request::task_ids::TaskIds<'a>>>,
46 pub process_id: Option<&'a str>,
47 pub user_endpoint:
48 Option<super::common::streams_group_heartbeat_request::endpoint::Endpoint<'a>>,
49 pub client_tags:
50 Option<Vec<super::common::streams_group_heartbeat_request::key_value::KeyValue<'a>>>,
51 pub task_offsets:
52 Option<Vec<super::common::streams_group_heartbeat_request::task_offset::TaskOffset<'a>>>,
53 pub task_end_offsets:
54 Option<Vec<super::common::streams_group_heartbeat_request::task_offset::TaskOffset<'a>>>,
55 pub shutdown_application: bool,
56 pub unknown_tagged_fields: UnknownTaggedFields,
57}
58impl Default for StreamsGroupHeartbeatRequest<'_> {
59 fn default() -> Self {
60 Self {
61 group_id: "",
62 member_id: "",
63 member_epoch: 0i32,
64 endpoint_information_epoch: 0i32,
65 instance_id: None,
66 rack_id: None,
67 rebalance_timeout_ms: -1i32,
68 topology: None,
69 active_tasks: None,
70 standby_tasks: None,
71 warmup_tasks: None,
72 process_id: None,
73 user_endpoint: None,
74 client_tags: None,
75 task_offsets: None,
76 task_end_offsets: None,
77 shutdown_application: false,
78 unknown_tagged_fields: UnknownTaggedFields::default(),
79 }
80 }
81}
82impl<'a> StreamsGroupHeartbeatRequest<'a> {
83 #[must_use]
87 pub fn to_owned(
88 &self,
89 ) -> crate::owned::streams_group_heartbeat_request::StreamsGroupHeartbeatRequest {
90 crate::owned::streams_group_heartbeat_request::StreamsGroupHeartbeatRequest {
91 group_id: (self.group_id).to_string(),
92 member_id: (self.member_id).to_string(),
93 member_epoch: (self.member_epoch),
94 endpoint_information_epoch: (self.endpoint_information_epoch),
95 instance_id: (self.instance_id).map(std::string::ToString::to_string),
96 rack_id: (self.rack_id).map(std::string::ToString::to_string),
97 rebalance_timeout_ms: (self.rebalance_timeout_ms),
98 topology: (self.topology).as_ref().map(Topology::to_owned),
99 active_tasks: (self.active_tasks).as_ref().map(|v| v.iter().map(super::common::streams_group_heartbeat_request::task_ids::TaskIds::to_owned).collect()),
100 standby_tasks: (self.standby_tasks).as_ref().map(|v| v.iter().map(super::common::streams_group_heartbeat_request::task_ids::TaskIds::to_owned).collect()),
101 warmup_tasks: (self.warmup_tasks).as_ref().map(|v| v.iter().map(super::common::streams_group_heartbeat_request::task_ids::TaskIds::to_owned).collect()),
102 process_id: (self.process_id).map(std::string::ToString::to_string),
103 user_endpoint: (self.user_endpoint).as_ref().map(super::common::streams_group_heartbeat_request::endpoint::Endpoint::to_owned),
104 client_tags: (self.client_tags).as_ref().map(|v| v.iter().map(super::common::streams_group_heartbeat_request::key_value::KeyValue::to_owned).collect()),
105 task_offsets: (self.task_offsets).as_ref().map(|v| v.iter().map(super::common::streams_group_heartbeat_request::task_offset::TaskOffset::to_owned).collect()),
106 task_end_offsets: (self.task_end_offsets).as_ref().map(|v| v.iter().map(super::common::streams_group_heartbeat_request::task_offset::TaskOffset::to_owned).collect()),
107 shutdown_application: (self.shutdown_application),
108 unknown_tagged_fields: self.unknown_tagged_fields.clone(),
109 }
110 }
111 fn encode_field_0<B: BufMut>(&self, buf: &mut B, version: i16, flex: bool) {
112 if version >= 0 {
113 if flex {
114 let () = put_compact_string(buf, self.group_id);
115 } else {
116 let () = put_string(buf, self.group_id);
117 }
118 }
119 }
120 fn encode_field_1<B: BufMut>(&self, buf: &mut B, version: i16, flex: bool) {
121 if version >= 0 {
122 if flex {
123 let () = put_compact_string(buf, self.member_id);
124 } else {
125 let () = put_string(buf, self.member_id);
126 }
127 }
128 }
129 fn encode_field_2<B: BufMut>(&self, buf: &mut B, version: i16, _flex: bool) {
130 if version >= 0 {
131 put_i32(buf, self.member_epoch);
132 }
133 }
134 fn encode_field_3<B: BufMut>(&self, buf: &mut B, version: i16, _flex: bool) {
135 if version >= 0 {
136 put_i32(buf, self.endpoint_information_epoch);
137 }
138 }
139 fn encode_field_4<B: BufMut>(&self, buf: &mut B, version: i16, flex: bool) {
140 if version >= 0 {
141 if flex {
142 let () = put_compact_nullable_string(buf, self.instance_id);
143 } else {
144 let () = put_nullable_string(buf, self.instance_id);
145 }
146 }
147 }
148 fn encode_field_5<B: BufMut>(&self, buf: &mut B, version: i16, flex: bool) {
149 if version >= 0 {
150 if flex {
151 let () = put_compact_nullable_string(buf, self.rack_id);
152 } else {
153 let () = put_nullable_string(buf, self.rack_id);
154 }
155 }
156 }
157 fn encode_field_6<B: BufMut>(&self, buf: &mut B, version: i16, _flex: bool) {
158 if version >= 0 {
159 put_i32(buf, self.rebalance_timeout_ms);
160 }
161 }
162 fn encode_field_7<B: BufMut>(
163 &self,
164 buf: &mut B,
165 version: i16,
166 _flex: bool,
167 ) -> Result<(), ProtocolError> {
168 if version >= 0 {
169 match &self.topology {
170 None => {
171 buf.put_i8(-1);
172 }
173 Some(v) => {
174 buf.put_i8(1);
175 v.encode(buf, version)?;
176 }
177 }
178 }
179 Ok(())
180 }
181 fn encode_field_8<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.active_tasks).as_ref().map(Vec::len);
190 crate::primitives::array::put_nullable_array_len(buf, len, flex);
191 if let Some(v) = &self.active_tasks {
192 for it in v {
193 it.encode(buf, version)?;
194 }
195 }
196 };
197 }
198 Ok(())
199 }
200 fn encode_field_9<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.standby_tasks).as_ref().map(Vec::len);
209 crate::primitives::array::put_nullable_array_len(buf, len, flex);
210 if let Some(v) = &self.standby_tasks {
211 for it in v {
212 it.encode(buf, version)?;
213 }
214 }
215 };
216 }
217 Ok(())
218 }
219 fn encode_field_10<B: BufMut>(
220 &self,
221 buf: &mut B,
222 version: i16,
223 flex: bool,
224 ) -> Result<(), ProtocolError> {
225 if version >= 0 {
226 {
227 let len = (self.warmup_tasks).as_ref().map(Vec::len);
228 crate::primitives::array::put_nullable_array_len(buf, len, flex);
229 if let Some(v) = &self.warmup_tasks {
230 for it in v {
231 it.encode(buf, version)?;
232 }
233 }
234 };
235 }
236 Ok(())
237 }
238 fn encode_field_11<B: BufMut>(&self, buf: &mut B, version: i16, flex: bool) {
239 if version >= 0 {
240 if flex {
241 let () = put_compact_nullable_string(buf, self.process_id);
242 } else {
243 let () = put_nullable_string(buf, self.process_id);
244 }
245 }
246 }
247 fn encode_field_12<B: BufMut>(
248 &self,
249 buf: &mut B,
250 version: i16,
251 _flex: bool,
252 ) -> Result<(), ProtocolError> {
253 if version >= 0 {
254 match &self.user_endpoint {
255 None => {
256 buf.put_i8(-1);
257 }
258 Some(v) => {
259 buf.put_i8(1);
260 v.encode(buf, version)?;
261 }
262 }
263 }
264 Ok(())
265 }
266 fn encode_field_13<B: BufMut>(
267 &self,
268 buf: &mut B,
269 version: i16,
270 flex: bool,
271 ) -> Result<(), ProtocolError> {
272 if version >= 0 {
273 {
274 let len = (self.client_tags).as_ref().map(Vec::len);
275 crate::primitives::array::put_nullable_array_len(buf, len, flex);
276 if let Some(v) = &self.client_tags {
277 for it in v {
278 it.encode(buf, version)?;
279 }
280 }
281 };
282 }
283 Ok(())
284 }
285 fn encode_field_14<B: BufMut>(
286 &self,
287 buf: &mut B,
288 version: i16,
289 flex: bool,
290 ) -> Result<(), ProtocolError> {
291 if version >= 0 {
292 {
293 let len = (self.task_offsets).as_ref().map(Vec::len);
294 crate::primitives::array::put_nullable_array_len(buf, len, flex);
295 if let Some(v) = &self.task_offsets {
296 for it in v {
297 it.encode(buf, version)?;
298 }
299 }
300 };
301 }
302 Ok(())
303 }
304 fn encode_field_15<B: BufMut>(
305 &self,
306 buf: &mut B,
307 version: i16,
308 flex: bool,
309 ) -> Result<(), ProtocolError> {
310 if version >= 0 {
311 {
312 let len = (self.task_end_offsets).as_ref().map(Vec::len);
313 crate::primitives::array::put_nullable_array_len(buf, len, flex);
314 if let Some(v) = &self.task_end_offsets {
315 for it in v {
316 it.encode(buf, version)?;
317 }
318 }
319 };
320 }
321 Ok(())
322 }
323 fn encode_field_16<B: BufMut>(&self, buf: &mut B, version: i16, _flex: bool) {
324 if version >= 0 {
325 put_bool(buf, self.shutdown_application);
326 }
327 }
328 fn encode_tagged_fields<B: BufMut>(&self, buf: &mut B, _version: i16, flex: bool) {
329 if flex {
330 let tagged = WriteTaggedFields::new();
331 tagged.write(buf, &self.unknown_tagged_fields);
332 }
333 }
334 fn decode_field_0(
335 out: &mut Self,
336 buf: &mut &'a [u8],
337 version: i16,
338 flex: bool,
339 ) -> Result<(), ProtocolError> {
340 if version >= 0 {
341 out.group_id = if flex {
342 get_compact_string_borrowed(buf)?
343 } else {
344 get_string_borrowed(buf)?
345 };
346 }
347 Ok(())
348 }
349 fn decode_field_1(
350 out: &mut Self,
351 buf: &mut &'a [u8],
352 version: i16,
353 flex: bool,
354 ) -> Result<(), ProtocolError> {
355 if version >= 0 {
356 out.member_id = if flex {
357 get_compact_string_borrowed(buf)?
358 } else {
359 get_string_borrowed(buf)?
360 };
361 }
362 Ok(())
363 }
364 fn decode_field_2(
365 out: &mut Self,
366 buf: &mut &'a [u8],
367 version: i16,
368 _flex: bool,
369 ) -> Result<(), ProtocolError> {
370 if version >= 0 {
371 out.member_epoch = get_i32(buf)?;
372 }
373 Ok(())
374 }
375 fn decode_field_3(
376 out: &mut Self,
377 buf: &mut &'a [u8],
378 version: i16,
379 _flex: bool,
380 ) -> Result<(), ProtocolError> {
381 if version >= 0 {
382 out.endpoint_information_epoch = get_i32(buf)?;
383 }
384 Ok(())
385 }
386 fn decode_field_4(
387 out: &mut Self,
388 buf: &mut &'a [u8],
389 version: i16,
390 flex: bool,
391 ) -> Result<(), ProtocolError> {
392 if version >= 0 {
393 out.instance_id = if flex {
394 get_compact_nullable_string_borrowed(buf)?
395 } else {
396 get_nullable_string_borrowed(buf)?
397 };
398 }
399 Ok(())
400 }
401 fn decode_field_5(
402 out: &mut Self,
403 buf: &mut &'a [u8],
404 version: i16,
405 flex: bool,
406 ) -> Result<(), ProtocolError> {
407 if version >= 0 {
408 out.rack_id = if flex {
409 get_compact_nullable_string_borrowed(buf)?
410 } else {
411 get_nullable_string_borrowed(buf)?
412 };
413 }
414 Ok(())
415 }
416 fn decode_field_6(
417 out: &mut Self,
418 buf: &mut &'a [u8],
419 version: i16,
420 _flex: bool,
421 ) -> Result<(), ProtocolError> {
422 if version >= 0 {
423 out.rebalance_timeout_ms = get_i32(buf)?;
424 }
425 Ok(())
426 }
427 fn decode_field_7(
428 out: &mut Self,
429 buf: &mut &'a [u8],
430 version: i16,
431 _flex: bool,
432 ) -> Result<(), ProtocolError> {
433 if version >= 0 {
434 out.topology = if get_i8(buf)? < 0 {
435 None
436 } else {
437 Some(Topology::decode_borrow(buf, version)?)
438 };
439 }
440 Ok(())
441 }
442 fn decode_field_8(
443 out: &mut Self,
444 buf: &mut &'a [u8],
445 version: i16,
446 flex: bool,
447 ) -> Result<(), ProtocolError> {
448 if version >= 0 {
449 out.active_tasks = {
450 let opt = crate::primitives::array::get_nullable_array_len(buf, flex)?;
451 match opt {
452 None => None,
453 Some(n) => {
454 let mut v = Vec::with_capacity(n);
455 for _ in 0..n {
456 v.push(super::common::streams_group_heartbeat_request::task_ids::TaskIds::decode_borrow(buf, version)?);
457 }
458 Some(v)
459 }
460 }
461 };
462 }
463 Ok(())
464 }
465 fn decode_field_9(
466 out: &mut Self,
467 buf: &mut &'a [u8],
468 version: i16,
469 flex: bool,
470 ) -> Result<(), ProtocolError> {
471 if version >= 0 {
472 out.standby_tasks = {
473 let opt = crate::primitives::array::get_nullable_array_len(buf, flex)?;
474 match opt {
475 None => None,
476 Some(n) => {
477 let mut v = Vec::with_capacity(n);
478 for _ in 0..n {
479 v.push(super::common::streams_group_heartbeat_request::task_ids::TaskIds::decode_borrow(buf, version)?);
480 }
481 Some(v)
482 }
483 }
484 };
485 }
486 Ok(())
487 }
488 fn decode_field_10(
489 out: &mut Self,
490 buf: &mut &'a [u8],
491 version: i16,
492 flex: bool,
493 ) -> Result<(), ProtocolError> {
494 if version >= 0 {
495 out.warmup_tasks = {
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(super::common::streams_group_heartbeat_request::task_ids::TaskIds::decode_borrow(buf, version)?);
503 }
504 Some(v)
505 }
506 }
507 };
508 }
509 Ok(())
510 }
511 fn decode_field_11(
512 out: &mut Self,
513 buf: &mut &'a [u8],
514 version: i16,
515 flex: bool,
516 ) -> Result<(), ProtocolError> {
517 if version >= 0 {
518 out.process_id = if flex {
519 get_compact_nullable_string_borrowed(buf)?
520 } else {
521 get_nullable_string_borrowed(buf)?
522 };
523 }
524 Ok(())
525 }
526 fn decode_field_12(
527 out: &mut Self,
528 buf: &mut &'a [u8],
529 version: i16,
530 _flex: bool,
531 ) -> Result<(), ProtocolError> {
532 if version >= 0 {
533 out.user_endpoint = if get_i8(buf)? < 0 {
534 None
535 } else {
536 Some(super::common::streams_group_heartbeat_request::endpoint::Endpoint::decode_borrow(buf, version)?)
537 };
538 }
539 Ok(())
540 }
541 fn decode_field_13(
542 out: &mut Self,
543 buf: &mut &'a [u8],
544 version: i16,
545 flex: bool,
546 ) -> Result<(), ProtocolError> {
547 if version >= 0 {
548 out.client_tags = {
549 let opt = crate::primitives::array::get_nullable_array_len(buf, flex)?;
550 match opt {
551 None => None,
552 Some(n) => {
553 let mut v = Vec::with_capacity(n);
554 for _ in 0..n {
555 v.push(super::common::streams_group_heartbeat_request::key_value::KeyValue::decode_borrow(buf, version)?);
556 }
557 Some(v)
558 }
559 }
560 };
561 }
562 Ok(())
563 }
564 fn decode_field_14(
565 out: &mut Self,
566 buf: &mut &'a [u8],
567 version: i16,
568 flex: bool,
569 ) -> Result<(), ProtocolError> {
570 if version >= 0 {
571 out.task_offsets = {
572 let opt = crate::primitives::array::get_nullable_array_len(buf, flex)?;
573 match opt {
574 None => None,
575 Some(n) => {
576 let mut v = Vec::with_capacity(n);
577 for _ in 0..n {
578 v.push(super::common::streams_group_heartbeat_request::task_offset::TaskOffset::decode_borrow(buf, version)?);
579 }
580 Some(v)
581 }
582 }
583 };
584 }
585 Ok(())
586 }
587 fn decode_field_15(
588 out: &mut Self,
589 buf: &mut &'a [u8],
590 version: i16,
591 flex: bool,
592 ) -> Result<(), ProtocolError> {
593 if version >= 0 {
594 out.task_end_offsets = {
595 let opt = crate::primitives::array::get_nullable_array_len(buf, flex)?;
596 match opt {
597 None => None,
598 Some(n) => {
599 let mut v = Vec::with_capacity(n);
600 for _ in 0..n {
601 v.push(super::common::streams_group_heartbeat_request::task_offset::TaskOffset::decode_borrow(buf, version)?);
602 }
603 Some(v)
604 }
605 }
606 };
607 }
608 Ok(())
609 }
610 fn decode_field_16(
611 out: &mut Self,
612 buf: &mut &'a [u8],
613 version: i16,
614 _flex: bool,
615 ) -> Result<(), ProtocolError> {
616 if version >= 0 {
617 out.shutdown_application = get_bool(buf)?;
618 }
619 Ok(())
620 }
621 fn decode_tagged_fields(
622 out: &mut Self,
623 buf: &mut &'a [u8],
624 _version: i16,
625 flex: bool,
626 ) -> Result<(), ProtocolError> {
627 if flex {
628 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
629 }
630 Ok(())
631 }
632}
633impl Encode for StreamsGroupHeartbeatRequest<'_> {
634 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
635 if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
636 return Err(ProtocolError::UnsupportedVersion {
637 api_key: API_KEY,
638 version,
639 });
640 }
641 let flex = is_flexible(version);
642 self.encode_field_0(buf, version, flex);
643 self.encode_field_1(buf, version, flex);
644 self.encode_field_2(buf, version, flex);
645 self.encode_field_3(buf, version, flex);
646 self.encode_field_4(buf, version, flex);
647 self.encode_field_5(buf, version, flex);
648 self.encode_field_6(buf, version, flex);
649 self.encode_field_7(buf, version, flex)?;
650 self.encode_field_8(buf, version, flex)?;
651 self.encode_field_9(buf, version, flex)?;
652 self.encode_field_10(buf, version, flex)?;
653 self.encode_field_11(buf, version, flex);
654 self.encode_field_12(buf, version, flex)?;
655 self.encode_field_13(buf, version, flex)?;
656 self.encode_field_14(buf, version, flex)?;
657 self.encode_field_15(buf, version, flex)?;
658 self.encode_field_16(buf, version, flex);
659 self.encode_tagged_fields(buf, version, flex);
660 Ok(())
661 }
662 fn encoded_len(&self, version: i16) -> usize {
663 let flex = is_flexible(version);
664 let mut n: usize = 0;
665 if version >= 0 {
666 n += if flex {
667 compact_string_len(self.group_id)
668 } else {
669 string_len(self.group_id)
670 };
671 }
672 if version >= 0 {
673 n += if flex {
674 compact_string_len(self.member_id)
675 } else {
676 string_len(self.member_id)
677 };
678 }
679 if version >= 0 {
680 n += 4;
681 }
682 if version >= 0 {
683 n += 4;
684 }
685 if version >= 0 {
686 n += if flex {
687 compact_nullable_string_len(self.instance_id)
688 } else {
689 nullable_string_len(self.instance_id)
690 };
691 }
692 if version >= 0 {
693 n += if flex {
694 compact_nullable_string_len(self.rack_id)
695 } else {
696 nullable_string_len(self.rack_id)
697 };
698 }
699 if version >= 0 {
700 n += 4;
701 }
702 if version >= 0 {
703 n += 1 + self.topology.as_ref().map_or(0, |v| v.encoded_len(version));
704 }
705 if version >= 0 {
706 n += {
707 let opt: Option<&Vec<_>> = (self.active_tasks).as_ref();
708 let prefix = crate::primitives::array::nullable_array_len_prefix_len(
709 opt.map(std::vec::Vec::len),
710 flex,
711 );
712 let body: usize =
713 opt.map_or(0, |v| v.iter().map(|it| it.encoded_len(version)).sum());
714 prefix + body
715 };
716 }
717 if version >= 0 {
718 n += {
719 let opt: Option<&Vec<_>> = (self.standby_tasks).as_ref();
720 let prefix = crate::primitives::array::nullable_array_len_prefix_len(
721 opt.map(std::vec::Vec::len),
722 flex,
723 );
724 let body: usize =
725 opt.map_or(0, |v| v.iter().map(|it| it.encoded_len(version)).sum());
726 prefix + body
727 };
728 }
729 if version >= 0 {
730 n += {
731 let opt: Option<&Vec<_>> = (self.warmup_tasks).as_ref();
732 let prefix = crate::primitives::array::nullable_array_len_prefix_len(
733 opt.map(std::vec::Vec::len),
734 flex,
735 );
736 let body: usize =
737 opt.map_or(0, |v| v.iter().map(|it| it.encoded_len(version)).sum());
738 prefix + body
739 };
740 }
741 if version >= 0 {
742 n += if flex {
743 compact_nullable_string_len(self.process_id)
744 } else {
745 nullable_string_len(self.process_id)
746 };
747 }
748 if version >= 0 {
749 n += 1 + self
750 .user_endpoint
751 .as_ref()
752 .map_or(0, |v| v.encoded_len(version));
753 }
754 if version >= 0 {
755 n += {
756 let opt: Option<&Vec<_>> = (self.client_tags).as_ref();
757 let prefix = crate::primitives::array::nullable_array_len_prefix_len(
758 opt.map(std::vec::Vec::len),
759 flex,
760 );
761 let body: usize =
762 opt.map_or(0, |v| v.iter().map(|it| it.encoded_len(version)).sum());
763 prefix + body
764 };
765 }
766 if version >= 0 {
767 n += {
768 let opt: Option<&Vec<_>> = (self.task_offsets).as_ref();
769 let prefix = crate::primitives::array::nullable_array_len_prefix_len(
770 opt.map(std::vec::Vec::len),
771 flex,
772 );
773 let body: usize =
774 opt.map_or(0, |v| v.iter().map(|it| it.encoded_len(version)).sum());
775 prefix + body
776 };
777 }
778 if version >= 0 {
779 n += {
780 let opt: Option<&Vec<_>> = (self.task_end_offsets).as_ref();
781 let prefix = crate::primitives::array::nullable_array_len_prefix_len(
782 opt.map(std::vec::Vec::len),
783 flex,
784 );
785 let body: usize =
786 opt.map_or(0, |v| v.iter().map(|it| it.encoded_len(version)).sum());
787 prefix + body
788 };
789 }
790 if version >= 0 {
791 n += 1;
792 }
793 if flex {
794 let known_pairs: Vec<(u32, usize)> = Vec::new();
795 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
796 }
797 n
798 }
799}
800impl<'de> DecodeBorrow<'de> for StreamsGroupHeartbeatRequest<'de> {
801 fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
802 if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
803 return Err(ProtocolError::UnsupportedVersion {
804 api_key: API_KEY,
805 version,
806 });
807 }
808 let flex = is_flexible(version);
809 let mut out = Self::default();
810 Self::decode_field_0(&mut out, buf, version, flex)?;
811 Self::decode_field_1(&mut out, buf, version, flex)?;
812 Self::decode_field_2(&mut out, buf, version, flex)?;
813 Self::decode_field_3(&mut out, buf, version, flex)?;
814 Self::decode_field_4(&mut out, buf, version, flex)?;
815 Self::decode_field_5(&mut out, buf, version, flex)?;
816 Self::decode_field_6(&mut out, buf, version, flex)?;
817 Self::decode_field_7(&mut out, buf, version, flex)?;
818 Self::decode_field_8(&mut out, buf, version, flex)?;
819 Self::decode_field_9(&mut out, buf, version, flex)?;
820 Self::decode_field_10(&mut out, buf, version, flex)?;
821 Self::decode_field_11(&mut out, buf, version, flex)?;
822 Self::decode_field_12(&mut out, buf, version, flex)?;
823 Self::decode_field_13(&mut out, buf, version, flex)?;
824 Self::decode_field_14(&mut out, buf, version, flex)?;
825 Self::decode_field_15(&mut out, buf, version, flex)?;
826 Self::decode_field_16(&mut out, buf, version, flex)?;
827 Self::decode_tagged_fields(&mut out, buf, version, flex)?;
828 Ok(out)
829 }
830}
831#[cfg(test)]
832impl StreamsGroupHeartbeatRequest<'_> {
833 #[must_use]
834 pub fn populated(version: i16) -> Self {
835 let mut m = Self::default();
836 if version >= 0 {
837 m.group_id = "x";
838 }
839 if version >= 0 {
840 m.member_id = "x";
841 }
842 if version >= 0 {
843 m.member_epoch = 1i32;
844 }
845 if version >= 0 {
846 m.endpoint_information_epoch = 1i32;
847 }
848 if version >= 0 {
849 m.instance_id = Some("x");
850 }
851 if version >= 0 {
852 m.rack_id = Some("x");
853 }
854 if version >= 0 {
855 m.rebalance_timeout_ms = 1i32;
856 }
857 if version >= 0 {
858 m.topology = Some(Topology::populated(version));
859 }
860 if version >= 0 {
861 m.active_tasks = Some(vec![
862 super::common::streams_group_heartbeat_request::task_ids::TaskIds::populated(
863 version,
864 ),
865 ]);
866 }
867 if version >= 0 {
868 m.standby_tasks = Some(vec![
869 super::common::streams_group_heartbeat_request::task_ids::TaskIds::populated(
870 version,
871 ),
872 ]);
873 }
874 if version >= 0 {
875 m.warmup_tasks = Some(vec![
876 super::common::streams_group_heartbeat_request::task_ids::TaskIds::populated(
877 version,
878 ),
879 ]);
880 }
881 if version >= 0 {
882 m.process_id = Some("x");
883 }
884 if version >= 0 {
885 m.user_endpoint = Some(
886 super::common::streams_group_heartbeat_request::endpoint::Endpoint::populated(
887 version,
888 ),
889 );
890 }
891 if version >= 0 {
892 m.client_tags = Some(vec![
893 super::common::streams_group_heartbeat_request::key_value::KeyValue::populated(
894 version,
895 ),
896 ]);
897 }
898 if version >= 0 {
899 m.task_offsets = Some(vec![
900 super::common::streams_group_heartbeat_request::task_offset::TaskOffset::populated(
901 version,
902 ),
903 ]);
904 }
905 if version >= 0 {
906 m.task_end_offsets = Some(vec![
907 super::common::streams_group_heartbeat_request::task_offset::TaskOffset::populated(
908 version,
909 ),
910 ]);
911 }
912 if version >= 0 {
913 m.shutdown_application = true;
914 }
915 m
916 }
917}
918#[derive(Debug, Clone, PartialEq, Eq, Default)]
919pub struct Topology<'a> {
920 pub epoch: i32,
921 pub subtopologies: Vec<Subtopology<'a>>,
922 pub unknown_tagged_fields: UnknownTaggedFields,
923}
924impl Topology<'_> {
925 #[must_use]
929 pub fn to_owned(&self) -> crate::owned::streams_group_heartbeat_request::Topology {
930 crate::owned::streams_group_heartbeat_request::Topology {
931 epoch: (self.epoch),
932 subtopologies: (self.subtopologies)
933 .iter()
934 .map(Subtopology::to_owned)
935 .collect(),
936 unknown_tagged_fields: self.unknown_tagged_fields.clone(),
937 }
938 }
939}
940impl Encode for Topology<'_> {
941 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
942 let flex = version >= 0;
943 if version >= 0 {
944 put_i32(buf, self.epoch);
945 }
946 if version >= 0 {
947 {
948 crate::primitives::array::put_array_len(buf, (self.subtopologies).len(), flex);
949 for it in &self.subtopologies {
950 it.encode(buf, version)?;
951 }
952 };
953 }
954 if flex {
955 let tagged = WriteTaggedFields::new();
956 tagged.write(buf, &self.unknown_tagged_fields);
957 }
958 Ok(())
959 }
960 fn encoded_len(&self, version: i16) -> usize {
961 let flex = version >= 0;
962 let mut n: usize = 0;
963 if version >= 0 {
964 n += 4;
965 }
966 if version >= 0 {
967 n += {
968 let prefix = crate::primitives::array::array_len_prefix_len(
969 (self.subtopologies).len(),
970 flex,
971 );
972 let body: usize = (self.subtopologies)
973 .iter()
974 .map(|it| it.encoded_len(version))
975 .sum();
976 prefix + body
977 };
978 }
979 if flex {
980 let known_pairs: Vec<(u32, usize)> = Vec::new();
981 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
982 }
983 n
984 }
985}
986impl<'de> DecodeBorrow<'de> for Topology<'de> {
987 fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
988 let flex = version >= 0;
989 let mut out = Self::default();
990 if version >= 0 {
991 out.epoch = get_i32(buf)?;
992 }
993 if version >= 0 {
994 out.subtopologies = {
995 let n = crate::primitives::array::get_array_len(buf, flex)?;
996 let mut v = Vec::with_capacity(n);
997 for _ in 0..n {
998 v.push(Subtopology::decode_borrow(buf, version)?);
999 }
1000 v
1001 };
1002 }
1003 if flex {
1004 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
1005 }
1006 Ok(out)
1007 }
1008}
1009#[cfg(test)]
1010impl Topology<'_> {
1011 #[must_use]
1012 pub fn populated(version: i16) -> Self {
1013 let mut m = Self::default();
1014 if version >= 0 {
1015 m.epoch = 1i32;
1016 }
1017 if version >= 0 {
1018 m.subtopologies = vec![Subtopology::populated(version)];
1019 }
1020 m
1021 }
1022}
1023#[derive(Debug, Clone, PartialEq, Eq, Default)]
1024pub struct Subtopology<'a> {
1025 pub subtopology_id: &'a str,
1026 pub source_topics: Vec<&'a str>,
1027 pub source_topic_regex: Vec<&'a str>,
1028 pub state_changelog_topics:
1029 Vec<super::common::streams_group_heartbeat_request::topic_info::TopicInfo<'a>>,
1030 pub repartition_sink_topics: Vec<&'a str>,
1031 pub repartition_source_topics:
1032 Vec<super::common::streams_group_heartbeat_request::topic_info::TopicInfo<'a>>,
1033 pub copartition_groups: Vec<CopartitionGroup>,
1034 pub unknown_tagged_fields: UnknownTaggedFields,
1035}
1036impl Subtopology<'_> {
1037 #[must_use]
1041 pub fn to_owned(&self) -> crate::owned::streams_group_heartbeat_request::Subtopology {
1042 crate::owned::streams_group_heartbeat_request::Subtopology {
1043 subtopology_id: (self.subtopology_id).to_string(),
1044 source_topics: (self.source_topics)
1045 .iter()
1046 .map(std::string::ToString::to_string)
1047 .collect(),
1048 source_topic_regex: (self.source_topic_regex)
1049 .iter()
1050 .map(std::string::ToString::to_string)
1051 .collect(),
1052 state_changelog_topics: (self.state_changelog_topics)
1053 .iter()
1054 .map(
1055 super::common::streams_group_heartbeat_request::topic_info::TopicInfo::to_owned,
1056 )
1057 .collect(),
1058 repartition_sink_topics: (self.repartition_sink_topics)
1059 .iter()
1060 .map(std::string::ToString::to_string)
1061 .collect(),
1062 repartition_source_topics: (self.repartition_source_topics)
1063 .iter()
1064 .map(
1065 super::common::streams_group_heartbeat_request::topic_info::TopicInfo::to_owned,
1066 )
1067 .collect(),
1068 copartition_groups: (self.copartition_groups)
1069 .iter()
1070 .map(CopartitionGroup::to_owned)
1071 .collect(),
1072 unknown_tagged_fields: self.unknown_tagged_fields.clone(),
1073 }
1074 }
1075}
1076impl Encode for Subtopology<'_> {
1077 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
1078 let flex = version >= 0;
1079 if version >= 0 {
1080 if flex {
1081 let () = put_compact_string(buf, self.subtopology_id);
1082 } else {
1083 let () = put_string(buf, self.subtopology_id);
1084 }
1085 }
1086 if version >= 0 {
1087 {
1088 crate::primitives::array::put_array_len(buf, (self.source_topics).len(), flex);
1089 for it in &self.source_topics {
1090 if flex {
1091 let () = put_compact_string(buf, it);
1092 } else {
1093 let () = put_string(buf, it);
1094 }
1095 }
1096 };
1097 }
1098 if version >= 0 {
1099 {
1100 crate::primitives::array::put_array_len(buf, (self.source_topic_regex).len(), flex);
1101 for it in &self.source_topic_regex {
1102 if flex {
1103 let () = put_compact_string(buf, it);
1104 } else {
1105 let () = put_string(buf, it);
1106 }
1107 }
1108 };
1109 }
1110 if version >= 0 {
1111 {
1112 crate::primitives::array::put_array_len(
1113 buf,
1114 (self.state_changelog_topics).len(),
1115 flex,
1116 );
1117 for it in &self.state_changelog_topics {
1118 it.encode(buf, version)?;
1119 }
1120 };
1121 }
1122 if version >= 0 {
1123 {
1124 crate::primitives::array::put_array_len(
1125 buf,
1126 (self.repartition_sink_topics).len(),
1127 flex,
1128 );
1129 for it in &self.repartition_sink_topics {
1130 if flex {
1131 let () = put_compact_string(buf, it);
1132 } else {
1133 let () = put_string(buf, it);
1134 }
1135 }
1136 };
1137 }
1138 if version >= 0 {
1139 {
1140 crate::primitives::array::put_array_len(
1141 buf,
1142 (self.repartition_source_topics).len(),
1143 flex,
1144 );
1145 for it in &self.repartition_source_topics {
1146 it.encode(buf, version)?;
1147 }
1148 };
1149 }
1150 if version >= 0 {
1151 {
1152 crate::primitives::array::put_array_len(buf, (self.copartition_groups).len(), flex);
1153 for it in &self.copartition_groups {
1154 it.encode(buf, version)?;
1155 }
1156 };
1157 }
1158 if flex {
1159 let tagged = WriteTaggedFields::new();
1160 tagged.write(buf, &self.unknown_tagged_fields);
1161 }
1162 Ok(())
1163 }
1164 fn encoded_len(&self, version: i16) -> usize {
1165 let flex = version >= 0;
1166 let mut n: usize = 0;
1167 if version >= 0 {
1168 n += if flex {
1169 compact_string_len(self.subtopology_id)
1170 } else {
1171 string_len(self.subtopology_id)
1172 };
1173 }
1174 if version >= 0 {
1175 n += {
1176 let prefix = crate::primitives::array::array_len_prefix_len(
1177 (self.source_topics).len(),
1178 flex,
1179 );
1180 let body: usize = (self.source_topics)
1181 .iter()
1182 .map(|it| {
1183 if flex {
1184 compact_string_len(it)
1185 } else {
1186 string_len(it)
1187 }
1188 })
1189 .sum();
1190 prefix + body
1191 };
1192 }
1193 if version >= 0 {
1194 n += {
1195 let prefix = crate::primitives::array::array_len_prefix_len(
1196 (self.source_topic_regex).len(),
1197 flex,
1198 );
1199 let body: usize = (self.source_topic_regex)
1200 .iter()
1201 .map(|it| {
1202 if flex {
1203 compact_string_len(it)
1204 } else {
1205 string_len(it)
1206 }
1207 })
1208 .sum();
1209 prefix + body
1210 };
1211 }
1212 if version >= 0 {
1213 n += {
1214 let prefix = crate::primitives::array::array_len_prefix_len(
1215 (self.state_changelog_topics).len(),
1216 flex,
1217 );
1218 let body: usize = (self.state_changelog_topics)
1219 .iter()
1220 .map(|it| it.encoded_len(version))
1221 .sum();
1222 prefix + body
1223 };
1224 }
1225 if version >= 0 {
1226 n += {
1227 let prefix = crate::primitives::array::array_len_prefix_len(
1228 (self.repartition_sink_topics).len(),
1229 flex,
1230 );
1231 let body: usize = (self.repartition_sink_topics)
1232 .iter()
1233 .map(|it| {
1234 if flex {
1235 compact_string_len(it)
1236 } else {
1237 string_len(it)
1238 }
1239 })
1240 .sum();
1241 prefix + body
1242 };
1243 }
1244 if version >= 0 {
1245 n += {
1246 let prefix = crate::primitives::array::array_len_prefix_len(
1247 (self.repartition_source_topics).len(),
1248 flex,
1249 );
1250 let body: usize = (self.repartition_source_topics)
1251 .iter()
1252 .map(|it| it.encoded_len(version))
1253 .sum();
1254 prefix + body
1255 };
1256 }
1257 if version >= 0 {
1258 n += {
1259 let prefix = crate::primitives::array::array_len_prefix_len(
1260 (self.copartition_groups).len(),
1261 flex,
1262 );
1263 let body: usize = (self.copartition_groups)
1264 .iter()
1265 .map(|it| it.encoded_len(version))
1266 .sum();
1267 prefix + body
1268 };
1269 }
1270 if flex {
1271 let known_pairs: Vec<(u32, usize)> = Vec::new();
1272 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
1273 }
1274 n
1275 }
1276}
1277impl<'de> DecodeBorrow<'de> for Subtopology<'de> {
1278 fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
1279 let flex = version >= 0;
1280 let mut out = Self::default();
1281 if version >= 0 {
1282 out.subtopology_id = if flex {
1283 get_compact_string_borrowed(buf)?
1284 } else {
1285 get_string_borrowed(buf)?
1286 };
1287 }
1288 if version >= 0 {
1289 out.source_topics = {
1290 let n = crate::primitives::array::get_array_len(buf, flex)?;
1291 let mut v = Vec::with_capacity(n);
1292 for _ in 0..n {
1293 v.push(if flex {
1294 get_compact_string_borrowed(buf)?
1295 } else {
1296 get_string_borrowed(buf)?
1297 });
1298 }
1299 v
1300 };
1301 }
1302 if version >= 0 {
1303 out.source_topic_regex = {
1304 let n = crate::primitives::array::get_array_len(buf, flex)?;
1305 let mut v = Vec::with_capacity(n);
1306 for _ in 0..n {
1307 v.push(if flex {
1308 get_compact_string_borrowed(buf)?
1309 } else {
1310 get_string_borrowed(buf)?
1311 });
1312 }
1313 v
1314 };
1315 }
1316 if version >= 0 {
1317 out.state_changelog_topics = {
1318 let n = crate::primitives::array::get_array_len(buf, flex)?;
1319 let mut v = Vec::with_capacity(n);
1320 for _ in 0..n {
1321 v.push(super::common::streams_group_heartbeat_request::topic_info::TopicInfo::decode_borrow(buf, version)?);
1322 }
1323 v
1324 };
1325 }
1326 if version >= 0 {
1327 out.repartition_sink_topics = {
1328 let n = crate::primitives::array::get_array_len(buf, flex)?;
1329 let mut v = Vec::with_capacity(n);
1330 for _ in 0..n {
1331 v.push(if flex {
1332 get_compact_string_borrowed(buf)?
1333 } else {
1334 get_string_borrowed(buf)?
1335 });
1336 }
1337 v
1338 };
1339 }
1340 if version >= 0 {
1341 out.repartition_source_topics = {
1342 let n = crate::primitives::array::get_array_len(buf, flex)?;
1343 let mut v = Vec::with_capacity(n);
1344 for _ in 0..n {
1345 v.push(super::common::streams_group_heartbeat_request::topic_info::TopicInfo::decode_borrow(buf, version)?);
1346 }
1347 v
1348 };
1349 }
1350 if version >= 0 {
1351 out.copartition_groups = {
1352 let n = crate::primitives::array::get_array_len(buf, flex)?;
1353 let mut v = Vec::with_capacity(n);
1354 for _ in 0..n {
1355 v.push(CopartitionGroup::decode_borrow(buf, version)?);
1356 }
1357 v
1358 };
1359 }
1360 if flex {
1361 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
1362 }
1363 Ok(out)
1364 }
1365}
1366#[cfg(test)]
1367impl Subtopology<'_> {
1368 #[must_use]
1369 pub fn populated(version: i16) -> Self {
1370 let mut m = Self::default();
1371 if version >= 0 {
1372 m.subtopology_id = "x";
1373 }
1374 if version >= 0 {
1375 m.source_topics = vec!["x"];
1376 }
1377 if version >= 0 {
1378 m.source_topic_regex = vec!["x"];
1379 }
1380 if version >= 0 {
1381 m.state_changelog_topics = vec![
1382 super::common::streams_group_heartbeat_request::topic_info::TopicInfo::populated(
1383 version,
1384 ),
1385 ];
1386 }
1387 if version >= 0 {
1388 m.repartition_sink_topics = vec!["x"];
1389 }
1390 if version >= 0 {
1391 m.repartition_source_topics = vec![
1392 super::common::streams_group_heartbeat_request::topic_info::TopicInfo::populated(
1393 version,
1394 ),
1395 ];
1396 }
1397 if version >= 0 {
1398 m.copartition_groups = vec![CopartitionGroup::populated(version)];
1399 }
1400 m
1401 }
1402}
1403#[derive(Debug, Clone, PartialEq, Eq, Default)]
1404pub struct CopartitionGroup {
1405 pub source_topics: Vec<i16>,
1406 pub source_topic_regex: Vec<i16>,
1407 pub repartition_source_topics: Vec<i16>,
1408 pub unknown_tagged_fields: UnknownTaggedFields,
1409}
1410impl CopartitionGroup {
1411 #[must_use]
1415 pub fn to_owned(&self) -> crate::owned::streams_group_heartbeat_request::CopartitionGroup {
1416 crate::owned::streams_group_heartbeat_request::CopartitionGroup {
1417 source_topics: (self.source_topics).clone(),
1418 source_topic_regex: (self.source_topic_regex).clone(),
1419 repartition_source_topics: (self.repartition_source_topics).clone(),
1420 unknown_tagged_fields: self.unknown_tagged_fields.clone(),
1421 }
1422 }
1423}
1424impl Encode for CopartitionGroup {
1425 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
1426 let flex = version >= 0;
1427 if version >= 0 {
1428 {
1429 crate::primitives::array::put_array_len(buf, (self.source_topics).len(), flex);
1430 for it in &self.source_topics {
1431 put_i16(buf, *it);
1432 }
1433 };
1434 }
1435 if version >= 0 {
1436 {
1437 crate::primitives::array::put_array_len(buf, (self.source_topic_regex).len(), flex);
1438 for it in &self.source_topic_regex {
1439 put_i16(buf, *it);
1440 }
1441 };
1442 }
1443 if version >= 0 {
1444 {
1445 crate::primitives::array::put_array_len(
1446 buf,
1447 (self.repartition_source_topics).len(),
1448 flex,
1449 );
1450 for it in &self.repartition_source_topics {
1451 put_i16(buf, *it);
1452 }
1453 };
1454 }
1455 if flex {
1456 let tagged = WriteTaggedFields::new();
1457 tagged.write(buf, &self.unknown_tagged_fields);
1458 }
1459 Ok(())
1460 }
1461 fn encoded_len(&self, version: i16) -> usize {
1462 let flex = version >= 0;
1463 let mut n: usize = 0;
1464 if version >= 0 {
1465 n += {
1466 let prefix = crate::primitives::array::array_len_prefix_len(
1467 (self.source_topics).len(),
1468 flex,
1469 );
1470 let body: usize = (self.source_topics).iter().map(|_| 2).sum();
1471 prefix + body
1472 };
1473 }
1474 if version >= 0 {
1475 n += {
1476 let prefix = crate::primitives::array::array_len_prefix_len(
1477 (self.source_topic_regex).len(),
1478 flex,
1479 );
1480 let body: usize = (self.source_topic_regex).iter().map(|_| 2).sum();
1481 prefix + body
1482 };
1483 }
1484 if version >= 0 {
1485 n += {
1486 let prefix = crate::primitives::array::array_len_prefix_len(
1487 (self.repartition_source_topics).len(),
1488 flex,
1489 );
1490 let body: usize = (self.repartition_source_topics).iter().map(|_| 2).sum();
1491 prefix + body
1492 };
1493 }
1494 if flex {
1495 let known_pairs: Vec<(u32, usize)> = Vec::new();
1496 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
1497 }
1498 n
1499 }
1500}
1501impl<'de> DecodeBorrow<'de> for CopartitionGroup {
1502 fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
1503 let flex = version >= 0;
1504 let mut out = Self::default();
1505 if version >= 0 {
1506 out.source_topics = {
1507 let n = crate::primitives::array::get_array_len(buf, flex)?;
1508 let mut v = Vec::with_capacity(n);
1509 for _ in 0..n {
1510 v.push(get_i16(buf)?);
1511 }
1512 v
1513 };
1514 }
1515 if version >= 0 {
1516 out.source_topic_regex = {
1517 let n = crate::primitives::array::get_array_len(buf, flex)?;
1518 let mut v = Vec::with_capacity(n);
1519 for _ in 0..n {
1520 v.push(get_i16(buf)?);
1521 }
1522 v
1523 };
1524 }
1525 if version >= 0 {
1526 out.repartition_source_topics = {
1527 let n = crate::primitives::array::get_array_len(buf, flex)?;
1528 let mut v = Vec::with_capacity(n);
1529 for _ in 0..n {
1530 v.push(get_i16(buf)?);
1531 }
1532 v
1533 };
1534 }
1535 if flex {
1536 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
1537 }
1538 Ok(out)
1539 }
1540}
1541#[cfg(test)]
1542impl CopartitionGroup {
1543 #[must_use]
1544 pub fn populated(version: i16) -> Self {
1545 let mut m = Self::default();
1546 if version >= 0 {
1547 m.source_topics = vec![1i16];
1548 }
1549 if version >= 0 {
1550 m.source_topic_regex = vec![1i16];
1551 }
1552 if version >= 0 {
1553 m.repartition_source_topics = vec![1i16];
1554 }
1555 m
1556 }
1557}