Skip to main content

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