Skip to main content

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