1use bytes::BufMut;
3
4use crate::{
5 DecodeBorrow, Encode, ProtocolError, UnknownTaggedFields,
6 primitives::{
7 fixed::{get_bool, 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 = 3;
21pub const MIN_VERSION: i16 = 0;
22pub const MAX_VERSION: i16 = 13;
23pub const FLEXIBLE_MIN: i16 = 9;
24#[inline]
25#[must_use]
26pub fn is_flexible(version: i16) -> bool {
27 version >= FLEXIBLE_MIN
28}
29#[derive(Debug, Clone, PartialEq, Eq)]
30pub struct MetadataResponse<'a> {
31 pub throttle_time_ms: i32,
32 pub brokers: Vec<MetadataResponseBroker<'a>>,
33 pub cluster_id: Option<&'a str>,
34 pub controller_id: i32,
35 pub topics: Vec<MetadataResponseTopic<'a>>,
36 pub cluster_authorized_operations: i32,
37 pub error_code: i16,
38 pub unknown_tagged_fields: UnknownTaggedFields,
39}
40impl Default for MetadataResponse<'_> {
41 fn default() -> Self {
42 Self {
43 throttle_time_ms: 0i32,
44 brokers: Vec::new(),
45 cluster_id: None,
46 controller_id: -1i32,
47 topics: Vec::new(),
48 cluster_authorized_operations: -2_147_483_648i32,
49 error_code: 0i16,
50 unknown_tagged_fields: UnknownTaggedFields::default(),
51 }
52 }
53}
54impl MetadataResponse<'_> {
55 #[must_use]
59 pub fn to_owned(&self) -> crate::owned::metadata_response::MetadataResponse {
60 crate::owned::metadata_response::MetadataResponse {
61 throttle_time_ms: (self.throttle_time_ms),
62 brokers: (self.brokers)
63 .iter()
64 .map(MetadataResponseBroker::to_owned)
65 .collect(),
66 cluster_id: (self.cluster_id).map(std::string::ToString::to_string),
67 controller_id: (self.controller_id),
68 topics: (self.topics)
69 .iter()
70 .map(MetadataResponseTopic::to_owned)
71 .collect(),
72 cluster_authorized_operations: (self.cluster_authorized_operations),
73 error_code: (self.error_code),
74 unknown_tagged_fields: self.unknown_tagged_fields.clone(),
75 }
76 }
77}
78impl Encode for MetadataResponse<'_> {
79 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
80 if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
81 return Err(ProtocolError::UnsupportedVersion {
82 api_key: API_KEY,
83 version,
84 });
85 }
86 let flex = is_flexible(version);
87 if version >= 3 {
88 put_i32(buf, self.throttle_time_ms);
89 }
90 if version >= 0 {
91 {
92 crate::primitives::array::put_array_len(buf, (self.brokers).len(), flex);
93 for it in &self.brokers {
94 it.encode(buf, version)?;
95 }
96 };
97 }
98 if version >= 2 {
99 if flex {
100 let () = put_compact_nullable_string(buf, self.cluster_id);
101 } else {
102 let () = put_nullable_string(buf, self.cluster_id);
103 }
104 }
105 if version >= 1 {
106 put_i32(buf, self.controller_id);
107 }
108 if version >= 0 {
109 {
110 crate::primitives::array::put_array_len(buf, (self.topics).len(), flex);
111 for it in &self.topics {
112 it.encode(buf, version)?;
113 }
114 };
115 }
116 if (8..=10).contains(&version) {
117 put_i32(buf, self.cluster_authorized_operations);
118 }
119 if version >= 13 {
120 put_i16(buf, self.error_code);
121 }
122 if flex {
123 let tagged = WriteTaggedFields::new();
124 tagged.write(buf, &self.unknown_tagged_fields);
125 }
126 Ok(())
127 }
128 fn encoded_len(&self, version: i16) -> usize {
129 let flex = is_flexible(version);
130 let mut n: usize = 0;
131 if version >= 3 {
132 n += 4;
133 }
134 if version >= 0 {
135 n += {
136 let prefix =
137 crate::primitives::array::array_len_prefix_len((self.brokers).len(), flex);
138 let body: usize = (self.brokers)
139 .iter()
140 .map(|it| it.encoded_len(version))
141 .sum();
142 prefix + body
143 };
144 }
145 if version >= 2 {
146 n += if flex {
147 compact_nullable_string_len(self.cluster_id)
148 } else {
149 nullable_string_len(self.cluster_id)
150 };
151 }
152 if version >= 1 {
153 n += 4;
154 }
155 if version >= 0 {
156 n += {
157 let prefix =
158 crate::primitives::array::array_len_prefix_len((self.topics).len(), flex);
159 let body: usize = (self.topics).iter().map(|it| it.encoded_len(version)).sum();
160 prefix + body
161 };
162 }
163 if (8..=10).contains(&version) {
164 n += 4;
165 }
166 if version >= 13 {
167 n += 2;
168 }
169 if flex {
170 let known_pairs: Vec<(u32, usize)> = Vec::new();
171 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
172 }
173 n
174 }
175}
176impl<'de> DecodeBorrow<'de> for MetadataResponse<'de> {
177 fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
178 if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
179 return Err(ProtocolError::UnsupportedVersion {
180 api_key: API_KEY,
181 version,
182 });
183 }
184 let flex = is_flexible(version);
185 let mut out = Self::default();
186 if version >= 3 {
187 out.throttle_time_ms = get_i32(buf)?;
188 }
189 if version >= 0 {
190 out.brokers = {
191 let n = crate::primitives::array::get_array_len(buf, flex)?;
192 let mut v = Vec::with_capacity(n);
193 for _ in 0..n {
194 v.push(MetadataResponseBroker::decode_borrow(buf, version)?);
195 }
196 v
197 };
198 }
199 if version >= 2 {
200 out.cluster_id = if flex {
201 get_compact_nullable_string_borrowed(buf)?
202 } else {
203 get_nullable_string_borrowed(buf)?
204 };
205 }
206 if version >= 1 {
207 out.controller_id = get_i32(buf)?;
208 }
209 if version >= 0 {
210 out.topics = {
211 let n = crate::primitives::array::get_array_len(buf, flex)?;
212 let mut v = Vec::with_capacity(n);
213 for _ in 0..n {
214 v.push(MetadataResponseTopic::decode_borrow(buf, version)?);
215 }
216 v
217 };
218 }
219 if (8..=10).contains(&version) {
220 out.cluster_authorized_operations = get_i32(buf)?;
221 }
222 if version >= 13 {
223 out.error_code = get_i16(buf)?;
224 }
225 if flex {
226 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
227 }
228 Ok(out)
229 }
230}
231#[cfg(test)]
232impl MetadataResponse<'_> {
233 #[must_use]
234 pub fn populated(version: i16) -> Self {
235 let mut m = Self::default();
236 if version >= 3 {
237 m.throttle_time_ms = 1i32;
238 }
239 if version >= 0 {
240 m.brokers = vec![MetadataResponseBroker::populated(version)];
241 }
242 if version >= 2 {
243 m.cluster_id = Some("x");
244 }
245 if version >= 1 {
246 m.controller_id = 1i32;
247 }
248 if version >= 0 {
249 m.topics = vec![MetadataResponseTopic::populated(version)];
250 }
251 if (8..=10).contains(&version) {
252 m.cluster_authorized_operations = 1i32;
253 }
254 if version >= 13 {
255 m.error_code = 1i16;
256 }
257 m
258 }
259}
260#[derive(Debug, Clone, PartialEq, Eq, Default)]
261pub struct MetadataResponseBroker<'a> {
262 pub node_id: i32,
263 pub host: &'a str,
264 pub port: i32,
265 pub rack: Option<&'a str>,
266 pub unknown_tagged_fields: UnknownTaggedFields,
267}
268impl MetadataResponseBroker<'_> {
269 #[must_use]
273 pub fn to_owned(&self) -> crate::owned::metadata_response::MetadataResponseBroker {
274 crate::owned::metadata_response::MetadataResponseBroker {
275 node_id: (self.node_id),
276 host: (self.host).to_string(),
277 port: (self.port),
278 rack: (self.rack).map(std::string::ToString::to_string),
279 unknown_tagged_fields: self.unknown_tagged_fields.clone(),
280 }
281 }
282}
283impl Encode for MetadataResponseBroker<'_> {
284 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
285 let flex = version >= 9;
286 if version >= 0 {
287 put_i32(buf, self.node_id);
288 }
289 if version >= 0 {
290 if flex {
291 let () = put_compact_string(buf, self.host);
292 } else {
293 let () = put_string(buf, self.host);
294 }
295 }
296 if version >= 0 {
297 put_i32(buf, self.port);
298 }
299 if version >= 1 {
300 if flex {
301 let () = put_compact_nullable_string(buf, self.rack);
302 } else {
303 let () = put_nullable_string(buf, self.rack);
304 }
305 }
306 if flex {
307 let tagged = WriteTaggedFields::new();
308 tagged.write(buf, &self.unknown_tagged_fields);
309 }
310 Ok(())
311 }
312 fn encoded_len(&self, version: i16) -> usize {
313 let flex = version >= 9;
314 let mut n: usize = 0;
315 if version >= 0 {
316 n += 4;
317 }
318 if version >= 0 {
319 n += if flex {
320 compact_string_len(self.host)
321 } else {
322 string_len(self.host)
323 };
324 }
325 if version >= 0 {
326 n += 4;
327 }
328 if version >= 1 {
329 n += if flex {
330 compact_nullable_string_len(self.rack)
331 } else {
332 nullable_string_len(self.rack)
333 };
334 }
335 if flex {
336 let known_pairs: Vec<(u32, usize)> = Vec::new();
337 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
338 }
339 n
340 }
341}
342impl<'de> DecodeBorrow<'de> for MetadataResponseBroker<'de> {
343 fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
344 let flex = version >= 9;
345 let mut out = Self::default();
346 if version >= 0 {
347 out.node_id = get_i32(buf)?;
348 }
349 if version >= 0 {
350 out.host = if flex {
351 get_compact_string_borrowed(buf)?
352 } else {
353 get_string_borrowed(buf)?
354 };
355 }
356 if version >= 0 {
357 out.port = get_i32(buf)?;
358 }
359 if version >= 1 {
360 out.rack = if flex {
361 get_compact_nullable_string_borrowed(buf)?
362 } else {
363 get_nullable_string_borrowed(buf)?
364 };
365 }
366 if flex {
367 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
368 }
369 Ok(out)
370 }
371}
372#[cfg(test)]
373impl MetadataResponseBroker<'_> {
374 #[must_use]
375 pub fn populated(version: i16) -> Self {
376 let mut m = Self::default();
377 if version >= 0 {
378 m.node_id = 1i32;
379 }
380 if version >= 0 {
381 m.host = "x";
382 }
383 if version >= 0 {
384 m.port = 1i32;
385 }
386 if version >= 1 {
387 m.rack = Some("x");
388 }
389 m
390 }
391}
392#[derive(Debug, Clone, PartialEq, Eq)]
393pub struct MetadataResponseTopic<'a> {
394 pub error_code: i16,
395 pub name: Option<&'a str>,
396 pub topic_id: crate::primitives::uuid::Uuid,
397 pub is_internal: bool,
398 pub partitions: Vec<MetadataResponsePartition>,
399 pub topic_authorized_operations: i32,
400 pub unknown_tagged_fields: UnknownTaggedFields,
401}
402impl Default for MetadataResponseTopic<'_> {
403 fn default() -> Self {
404 Self {
405 error_code: 0i16,
406 name: Some(""),
407 topic_id: crate::primitives::uuid::Uuid::default(),
408 is_internal: false,
409 partitions: Vec::new(),
410 topic_authorized_operations: -2_147_483_648i32,
411 unknown_tagged_fields: UnknownTaggedFields::default(),
412 }
413 }
414}
415impl MetadataResponseTopic<'_> {
416 #[must_use]
420 pub fn to_owned(&self) -> crate::owned::metadata_response::MetadataResponseTopic {
421 crate::owned::metadata_response::MetadataResponseTopic {
422 error_code: (self.error_code),
423 name: (self.name).map(std::string::ToString::to_string),
424 topic_id: (self.topic_id),
425 is_internal: (self.is_internal),
426 partitions: (self.partitions)
427 .iter()
428 .map(MetadataResponsePartition::to_owned)
429 .collect(),
430 topic_authorized_operations: (self.topic_authorized_operations),
431 unknown_tagged_fields: self.unknown_tagged_fields.clone(),
432 }
433 }
434}
435impl Encode for MetadataResponseTopic<'_> {
436 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
437 let flex = version >= 9;
438 if version >= 0 {
439 put_i16(buf, self.error_code);
440 }
441 if version >= 0 {
442 if version >= 12 {
443 if flex {
444 let () = put_compact_nullable_string(buf, self.name);
445 } else {
446 let () = put_nullable_string(buf, self.name);
447 }
448 } else {
449 if flex {
450 let () = put_compact_string(buf, (self.name).unwrap_or(""));
451 } else {
452 let () = put_string(buf, (self.name).unwrap_or(""));
453 }
454 }
455 }
456 if version >= 10 {
457 crate::primitives::uuid::put_uuid(buf, self.topic_id);
458 }
459 if version >= 1 {
460 put_bool(buf, self.is_internal);
461 }
462 if version >= 0 {
463 {
464 crate::primitives::array::put_array_len(buf, (self.partitions).len(), flex);
465 for it in &self.partitions {
466 it.encode(buf, version)?;
467 }
468 };
469 }
470 if version >= 8 {
471 put_i32(buf, self.topic_authorized_operations);
472 }
473 if flex {
474 let tagged = WriteTaggedFields::new();
475 tagged.write(buf, &self.unknown_tagged_fields);
476 }
477 Ok(())
478 }
479 fn encoded_len(&self, version: i16) -> usize {
480 let flex = version >= 9;
481 let mut n: usize = 0;
482 if version >= 0 {
483 n += 2;
484 }
485 if version >= 0 {
486 n += if version >= 12 {
487 if flex {
488 compact_nullable_string_len(self.name)
489 } else {
490 nullable_string_len(self.name)
491 }
492 } else {
493 if flex {
494 compact_string_len((self.name).unwrap_or(""))
495 } else {
496 string_len((self.name).unwrap_or(""))
497 }
498 };
499 }
500 if version >= 10 {
501 n += 16;
502 }
503 if version >= 1 {
504 n += 1;
505 }
506 if version >= 0 {
507 n += {
508 let prefix =
509 crate::primitives::array::array_len_prefix_len((self.partitions).len(), flex);
510 let body: usize = (self.partitions)
511 .iter()
512 .map(|it| it.encoded_len(version))
513 .sum();
514 prefix + body
515 };
516 }
517 if version >= 8 {
518 n += 4;
519 }
520 if flex {
521 let known_pairs: Vec<(u32, usize)> = Vec::new();
522 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
523 }
524 n
525 }
526}
527impl<'de> DecodeBorrow<'de> for MetadataResponseTopic<'de> {
528 fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
529 let flex = version >= 9;
530 let mut out = Self::default();
531 if version >= 0 {
532 out.error_code = get_i16(buf)?;
533 }
534 if version >= 0 {
535 out.name = if version >= 12 {
536 if flex {
537 get_compact_nullable_string_borrowed(buf)?
538 } else {
539 get_nullable_string_borrowed(buf)?
540 }
541 } else {
542 Some(if flex {
543 get_compact_string_borrowed(buf)?
544 } else {
545 get_string_borrowed(buf)?
546 })
547 };
548 }
549 if version >= 10 {
550 out.topic_id = crate::primitives::uuid::get_uuid(buf)?;
551 }
552 if version >= 1 {
553 out.is_internal = get_bool(buf)?;
554 }
555 if version >= 0 {
556 out.partitions = {
557 let n = crate::primitives::array::get_array_len(buf, flex)?;
558 let mut v = Vec::with_capacity(n);
559 for _ in 0..n {
560 v.push(MetadataResponsePartition::decode_borrow(buf, version)?);
561 }
562 v
563 };
564 }
565 if version >= 8 {
566 out.topic_authorized_operations = get_i32(buf)?;
567 }
568 if flex {
569 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
570 }
571 Ok(out)
572 }
573}
574#[cfg(test)]
575impl MetadataResponseTopic<'_> {
576 #[must_use]
577 pub fn populated(version: i16) -> Self {
578 let mut m = Self::default();
579 if version >= 0 {
580 m.error_code = 1i16;
581 }
582 if version >= 0 {
583 m.name = Some("x");
584 }
585 if version >= 10 {
586 m.topic_id = crate::primitives::uuid::Uuid([1u8; 16]);
587 }
588 if version >= 1 {
589 m.is_internal = true;
590 }
591 if version >= 0 {
592 m.partitions = vec![MetadataResponsePartition::populated(version)];
593 }
594 if version >= 8 {
595 m.topic_authorized_operations = 1i32;
596 }
597 m
598 }
599}
600#[derive(Debug, Clone, PartialEq, Eq)]
601pub struct MetadataResponsePartition {
602 pub error_code: i16,
603 pub partition_index: i32,
604 pub leader_id: i32,
605 pub leader_epoch: i32,
606 pub replica_nodes: Vec<i32>,
607 pub isr_nodes: Vec<i32>,
608 pub offline_replicas: Vec<i32>,
609 pub unknown_tagged_fields: UnknownTaggedFields,
610}
611impl Default for MetadataResponsePartition {
612 fn default() -> Self {
613 Self {
614 error_code: 0i16,
615 partition_index: 0i32,
616 leader_id: 0i32,
617 leader_epoch: -1i32,
618 replica_nodes: Vec::new(),
619 isr_nodes: Vec::new(),
620 offline_replicas: Vec::new(),
621 unknown_tagged_fields: UnknownTaggedFields::default(),
622 }
623 }
624}
625impl MetadataResponsePartition {
626 #[must_use]
630 pub fn to_owned(&self) -> crate::owned::metadata_response::MetadataResponsePartition {
631 crate::owned::metadata_response::MetadataResponsePartition {
632 error_code: (self.error_code),
633 partition_index: (self.partition_index),
634 leader_id: (self.leader_id),
635 leader_epoch: (self.leader_epoch),
636 replica_nodes: (self.replica_nodes).clone(),
637 isr_nodes: (self.isr_nodes).clone(),
638 offline_replicas: (self.offline_replicas).clone(),
639 unknown_tagged_fields: self.unknown_tagged_fields.clone(),
640 }
641 }
642}
643impl Encode for MetadataResponsePartition {
644 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
645 let flex = version >= 9;
646 if version >= 0 {
647 put_i16(buf, self.error_code);
648 }
649 if version >= 0 {
650 put_i32(buf, self.partition_index);
651 }
652 if version >= 0 {
653 put_i32(buf, self.leader_id);
654 }
655 if version >= 7 {
656 put_i32(buf, self.leader_epoch);
657 }
658 if version >= 0 {
659 {
660 crate::primitives::array::put_array_len(buf, (self.replica_nodes).len(), flex);
661 for it in &self.replica_nodes {
662 put_i32(buf, *it);
663 }
664 };
665 }
666 if version >= 0 {
667 {
668 crate::primitives::array::put_array_len(buf, (self.isr_nodes).len(), flex);
669 for it in &self.isr_nodes {
670 put_i32(buf, *it);
671 }
672 };
673 }
674 if version >= 5 {
675 {
676 crate::primitives::array::put_array_len(buf, (self.offline_replicas).len(), flex);
677 for it in &self.offline_replicas {
678 put_i32(buf, *it);
679 }
680 };
681 }
682 if flex {
683 let tagged = WriteTaggedFields::new();
684 tagged.write(buf, &self.unknown_tagged_fields);
685 }
686 Ok(())
687 }
688 fn encoded_len(&self, version: i16) -> usize {
689 let flex = version >= 9;
690 let mut n: usize = 0;
691 if version >= 0 {
692 n += 2;
693 }
694 if version >= 0 {
695 n += 4;
696 }
697 if version >= 0 {
698 n += 4;
699 }
700 if version >= 7 {
701 n += 4;
702 }
703 if version >= 0 {
704 n += {
705 let prefix = crate::primitives::array::array_len_prefix_len(
706 (self.replica_nodes).len(),
707 flex,
708 );
709 let body: usize = (self.replica_nodes).iter().map(|_| 4).sum();
710 prefix + body
711 };
712 }
713 if version >= 0 {
714 n += {
715 let prefix =
716 crate::primitives::array::array_len_prefix_len((self.isr_nodes).len(), flex);
717 let body: usize = (self.isr_nodes).iter().map(|_| 4).sum();
718 prefix + body
719 };
720 }
721 if version >= 5 {
722 n += {
723 let prefix = crate::primitives::array::array_len_prefix_len(
724 (self.offline_replicas).len(),
725 flex,
726 );
727 let body: usize = (self.offline_replicas).iter().map(|_| 4).sum();
728 prefix + body
729 };
730 }
731 if flex {
732 let known_pairs: Vec<(u32, usize)> = Vec::new();
733 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
734 }
735 n
736 }
737}
738impl<'de> DecodeBorrow<'de> for MetadataResponsePartition {
739 fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
740 let flex = version >= 9;
741 let mut out = Self::default();
742 if version >= 0 {
743 out.error_code = get_i16(buf)?;
744 }
745 if version >= 0 {
746 out.partition_index = get_i32(buf)?;
747 }
748 if version >= 0 {
749 out.leader_id = get_i32(buf)?;
750 }
751 if version >= 7 {
752 out.leader_epoch = get_i32(buf)?;
753 }
754 if version >= 0 {
755 out.replica_nodes = {
756 let n = crate::primitives::array::get_array_len(buf, flex)?;
757 let mut v = Vec::with_capacity(n);
758 for _ in 0..n {
759 v.push(get_i32(buf)?);
760 }
761 v
762 };
763 }
764 if version >= 0 {
765 out.isr_nodes = {
766 let n = crate::primitives::array::get_array_len(buf, flex)?;
767 let mut v = Vec::with_capacity(n);
768 for _ in 0..n {
769 v.push(get_i32(buf)?);
770 }
771 v
772 };
773 }
774 if version >= 5 {
775 out.offline_replicas = {
776 let n = crate::primitives::array::get_array_len(buf, flex)?;
777 let mut v = Vec::with_capacity(n);
778 for _ in 0..n {
779 v.push(get_i32(buf)?);
780 }
781 v
782 };
783 }
784 if flex {
785 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
786 }
787 Ok(out)
788 }
789}
790#[cfg(test)]
791impl MetadataResponsePartition {
792 #[must_use]
793 pub fn populated(version: i16) -> Self {
794 let mut m = Self::default();
795 if version >= 0 {
796 m.error_code = 1i16;
797 }
798 if version >= 0 {
799 m.partition_index = 1i32;
800 }
801 if version >= 0 {
802 m.leader_id = 1i32;
803 }
804 if version >= 7 {
805 m.leader_epoch = 1i32;
806 }
807 if version >= 0 {
808 m.replica_nodes = vec![1i32];
809 }
810 if version >= 0 {
811 m.isr_nodes = vec![1i32];
812 }
813 if version >= 5 {
814 m.offline_replicas = vec![1i32];
815 }
816 m
817 }
818}