Skip to main content

krabka_protocol/opt/rustwide/workdir/generated/
DescribeConfigsResponse.borrowed.rs

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