Skip to main content

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