Skip to main content

crabka_protocol/opt/rustwide/workdir/generated/
MetadataResponse.borrowed.rs

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