Skip to main content

kacrab_protocol/generated/
describe_configs_response.rs

1//! Generated from DescribeConfigsResponse.json - DO NOT EDIT
2#![allow(
3    missing_docs,
4    clippy::all,
5    clippy::pedantic,
6    clippy::nursery,
7    clippy::arithmetic_side_effects,
8    reason = "Generated protocol modules mirror Kafka's schema shape and intentionally trade \
9              hand-written lint style for reproducible wire-code output."
10)]
11use bytes::{Bytes, BytesMut};
12
13use crate::*;
14
15#[derive(Debug, Clone, PartialEq)]
16pub struct DescribeConfigsResponseData {
17    /// The duration in milliseconds for which the request was throttled due to a quota violation,
18    /// or zero if the request did not violate any quota.
19    pub throttle_time_ms: i32,
20    /// The results for each resource.
21    pub results: Vec<DescribeConfigsResult>,
22    pub _unknown_tagged_fields: Vec<RawTaggedField>,
23}
24impl Default for DescribeConfigsResponseData {
25    fn default() -> Self {
26        Self {
27            throttle_time_ms: 0_i32,
28            results: Vec::new(),
29            _unknown_tagged_fields: Vec::new(),
30        }
31    }
32}
33impl DescribeConfigsResponseData {
34    pub fn with_throttle_time_ms(mut self, value: i32) -> Self {
35        self.throttle_time_ms = value;
36        self
37    }
38    pub fn with_results(mut self, value: Vec<DescribeConfigsResult>) -> Self {
39        self.results = value;
40        self
41    }
42    pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
43        if version < 1 || version > 4 {
44            return Err(UnsupportedVersion::new(32, version).into());
45        }
46        let throttle_time_ms;
47        let results;
48        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
49        throttle_time_ms = read_i32(buf)?;
50        if version >= 4 {
51            results = {
52                let len = read_compact_array_length(buf)?;
53                let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
54                for _ in 0..len {
55                    arr.push(DescribeConfigsResult::read(buf, version)?);
56                }
57                arr
58            };
59        } else {
60            results = {
61                let len = read_array_length(buf)?;
62                let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
63                for _ in 0..len {
64                    arr.push(DescribeConfigsResult::read(buf, version)?);
65                }
66                arr
67            };
68        }
69        if version >= 4 {
70            let tagged_fields = read_tagged_fields(buf)?;
71            for field in &tagged_fields {
72                match field.tag {
73                    _ => {
74                        _unknown_tagged_fields.push(field.clone());
75                    },
76                }
77            }
78        }
79        Ok(Self {
80            throttle_time_ms,
81            results,
82            _unknown_tagged_fields,
83        })
84    }
85    pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
86        if version < 1 || version > 4 {
87            return Err(UnsupportedVersion::new(32, version).into());
88        }
89        write_i32(buf, self.throttle_time_ms);
90        if version >= 4 {
91            write_compact_array_length(buf, self.results.len() as i32);
92            for el in &self.results {
93                el.write(buf, version)?;
94            }
95        } else {
96            write_array_length(buf, self.results.len() as i32);
97            for el in &self.results {
98                el.write(buf, version)?;
99            }
100        }
101        if version >= 4 {
102            let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
103            all_tags.sort_by_key(|f| f.tag);
104            write_tagged_fields(buf, &all_tags)?;
105        }
106        Ok(())
107    }
108    pub fn encoded_len(&self, version: i16) -> Result<usize> {
109        if version < 1 || version > 4 {
110            return Err(UnsupportedVersion::new(32, version).into());
111        }
112        let mut len: usize = 0;
113        len += 4;
114        if version >= 4 {
115            len += compact_array_length_len(self.results.len() as i32);
116            for el in &self.results {
117                len += el.encoded_len(version)?;
118            }
119        } else {
120            len += array_length_len();
121            for el in &self.results {
122                len += el.encoded_len(version)?;
123            }
124        }
125        if version >= 4 {
126            let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
127            all_tags.sort_by_key(|f| f.tag);
128            len += tagged_fields_len(&all_tags)?;
129        }
130        Ok(len)
131    }
132}
133#[derive(Debug, Clone, PartialEq)]
134pub struct DescribeConfigsResult {
135    /// The error code, or 0 if we were able to successfully describe the configurations.
136    pub error_code: i16,
137    /// The error message, or null if we were able to successfully describe the configurations.
138    pub error_message: Option<KafkaString>,
139    /// The resource type.
140    pub resource_type: i8,
141    /// The resource name.
142    pub resource_name: KafkaString,
143    /// Each listed configuration.
144    pub configs: Vec<DescribeConfigsResourceResult>,
145    pub _unknown_tagged_fields: Vec<RawTaggedField>,
146}
147impl Default for DescribeConfigsResult {
148    fn default() -> Self {
149        Self {
150            error_code: 0_i16,
151            error_message: None,
152            resource_type: 0_i8,
153            resource_name: KafkaString::default(),
154            configs: Vec::new(),
155            _unknown_tagged_fields: Vec::new(),
156        }
157    }
158}
159impl DescribeConfigsResult {
160    pub fn with_error_code(mut self, value: i16) -> Self {
161        self.error_code = value;
162        self
163    }
164    pub fn with_error_message(mut self, value: Option<KafkaString>) -> Self {
165        self.error_message = value;
166        self
167    }
168    pub fn with_resource_type(mut self, value: i8) -> Self {
169        self.resource_type = value;
170        self
171    }
172    pub fn with_resource_name(mut self, value: KafkaString) -> Self {
173        self.resource_name = value;
174        self
175    }
176    pub fn with_configs(mut self, value: Vec<DescribeConfigsResourceResult>) -> Self {
177        self.configs = value;
178        self
179    }
180    pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
181        let error_code;
182        let error_message;
183        let resource_type;
184        let resource_name;
185        let configs;
186        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
187        error_code = read_i16(buf)?;
188        if version >= 4 {
189            error_message = read_compact_nullable_string(buf)?;
190        } else {
191            error_message = read_nullable_string(buf)?;
192        }
193        resource_type = read_i8(buf)?;
194        if version >= 4 {
195            resource_name = read_compact_string(buf)?;
196        } else {
197            resource_name = read_string(buf)?;
198        }
199        if version >= 4 {
200            configs = {
201                let len = read_compact_array_length(buf)?;
202                let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
203                for _ in 0..len {
204                    arr.push(DescribeConfigsResourceResult::read(buf, version)?);
205                }
206                arr
207            };
208        } else {
209            configs = {
210                let len = read_array_length(buf)?;
211                let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
212                for _ in 0..len {
213                    arr.push(DescribeConfigsResourceResult::read(buf, version)?);
214                }
215                arr
216            };
217        }
218        if version >= 4 {
219            let tagged_fields = read_tagged_fields(buf)?;
220            for field in &tagged_fields {
221                match field.tag {
222                    _ => {
223                        _unknown_tagged_fields.push(field.clone());
224                    },
225                }
226            }
227        }
228        Ok(Self {
229            error_code,
230            error_message,
231            resource_type,
232            resource_name,
233            configs,
234            _unknown_tagged_fields,
235        })
236    }
237    pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
238        write_i16(buf, self.error_code);
239        if version >= 4 {
240            write_compact_nullable_string(buf, self.error_message.as_ref())?;
241        } else {
242            write_nullable_string(buf, self.error_message.as_ref())?;
243        }
244        write_i8(buf, self.resource_type);
245        if version >= 4 {
246            write_compact_string(buf, &self.resource_name)?;
247        } else {
248            write_string(buf, &self.resource_name)?;
249        }
250        if version >= 4 {
251            write_compact_array_length(buf, self.configs.len() as i32);
252            for el in &self.configs {
253                el.write(buf, version)?;
254            }
255        } else {
256            write_array_length(buf, self.configs.len() as i32);
257            for el in &self.configs {
258                el.write(buf, version)?;
259            }
260        }
261        if version >= 4 {
262            let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
263            all_tags.sort_by_key(|f| f.tag);
264            write_tagged_fields(buf, &all_tags)?;
265        }
266        Ok(())
267    }
268    pub fn encoded_len(&self, version: i16) -> Result<usize> {
269        let mut len: usize = 0;
270        len += 2;
271        if version >= 4 {
272            len += compact_nullable_string_len(self.error_message.as_ref())?;
273        } else {
274            len += nullable_string_len(self.error_message.as_ref())?;
275        }
276        len += 1;
277        if version >= 4 {
278            len += compact_string_len(&self.resource_name)?;
279        } else {
280            len += string_len(&self.resource_name)?;
281        }
282        if version >= 4 {
283            len += compact_array_length_len(self.configs.len() as i32);
284            for el in &self.configs {
285                len += el.encoded_len(version)?;
286            }
287        } else {
288            len += array_length_len();
289            for el in &self.configs {
290                len += el.encoded_len(version)?;
291            }
292        }
293        if version >= 4 {
294            let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
295            all_tags.sort_by_key(|f| f.tag);
296            len += tagged_fields_len(&all_tags)?;
297        }
298        Ok(len)
299    }
300}
301#[derive(Debug, Clone, PartialEq)]
302pub struct DescribeConfigsResourceResult {
303    /// The configuration name.
304    pub name: KafkaString,
305    /// The configuration value.
306    pub value: Option<KafkaString>,
307    /// True if the configuration is read-only.
308    pub read_only: bool,
309    /// The configuration source.
310    pub config_source: i8,
311    /// True if this configuration is sensitive.
312    pub is_sensitive: bool,
313    /// The synonyms for this configuration key.
314    pub synonyms: Vec<DescribeConfigsSynonym>,
315    /// The configuration data type. Type can be one of the following values - BOOLEAN, STRING,
316    /// INT, SHORT, LONG, DOUBLE, LIST, CLASS, PASSWORD.
317    pub config_type: i8,
318    /// The configuration documentation.
319    pub documentation: Option<KafkaString>,
320    pub _unknown_tagged_fields: Vec<RawTaggedField>,
321}
322impl Default for DescribeConfigsResourceResult {
323    fn default() -> Self {
324        Self {
325            name: KafkaString::default(),
326            value: None,
327            read_only: false,
328            config_source: -1i8,
329            is_sensitive: false,
330            synonyms: Vec::new(),
331            config_type: 0i8,
332            documentation: None,
333            _unknown_tagged_fields: Vec::new(),
334        }
335    }
336}
337impl DescribeConfigsResourceResult {
338    pub fn with_name(mut self, value: KafkaString) -> Self {
339        self.name = value;
340        self
341    }
342    pub fn with_value(mut self, value: Option<KafkaString>) -> Self {
343        self.value = value;
344        self
345    }
346    pub fn with_read_only(mut self, value: bool) -> Self {
347        self.read_only = value;
348        self
349    }
350    pub fn with_config_source(mut self, value: i8) -> Self {
351        self.config_source = value;
352        self
353    }
354    pub fn with_is_sensitive(mut self, value: bool) -> Self {
355        self.is_sensitive = value;
356        self
357    }
358    pub fn with_synonyms(mut self, value: Vec<DescribeConfigsSynonym>) -> Self {
359        self.synonyms = value;
360        self
361    }
362    pub fn with_config_type(mut self, value: i8) -> Self {
363        self.config_type = value;
364        self
365    }
366    pub fn with_documentation(mut self, value: Option<KafkaString>) -> Self {
367        self.documentation = value;
368        self
369    }
370    pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
371        let name;
372        let value;
373        let read_only;
374        let config_source;
375        let is_sensitive;
376        let synonyms;
377        let mut config_type = 0i8;
378        let mut documentation = None;
379        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
380        if version >= 4 {
381            name = read_compact_string(buf)?;
382        } else {
383            name = read_string(buf)?;
384        }
385        if version >= 4 {
386            value = read_compact_nullable_string(buf)?;
387        } else {
388            value = read_nullable_string(buf)?;
389        }
390        read_only = read_bool(buf)?;
391        config_source = read_i8(buf)?;
392        is_sensitive = read_bool(buf)?;
393        if version >= 4 {
394            synonyms = {
395                let len = read_compact_array_length(buf)?;
396                let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
397                for _ in 0..len {
398                    arr.push(DescribeConfigsSynonym::read(buf, version)?);
399                }
400                arr
401            };
402        } else {
403            synonyms = {
404                let len = read_array_length(buf)?;
405                let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
406                for _ in 0..len {
407                    arr.push(DescribeConfigsSynonym::read(buf, version)?);
408                }
409                arr
410            };
411        }
412        if version >= 3 {
413            config_type = read_i8(buf)?;
414        }
415        if version >= 3 {
416            if version >= 4 {
417                documentation = read_compact_nullable_string(buf)?;
418            } else {
419                documentation = read_nullable_string(buf)?;
420            }
421        }
422        if version >= 4 {
423            let tagged_fields = read_tagged_fields(buf)?;
424            for field in &tagged_fields {
425                match field.tag {
426                    _ => {
427                        _unknown_tagged_fields.push(field.clone());
428                    },
429                }
430            }
431        }
432        Ok(Self {
433            name,
434            value,
435            read_only,
436            config_source,
437            is_sensitive,
438            synonyms,
439            config_type,
440            documentation,
441            _unknown_tagged_fields,
442        })
443    }
444    pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
445        if version >= 4 {
446            write_compact_string(buf, &self.name)?;
447        } else {
448            write_string(buf, &self.name)?;
449        }
450        if version >= 4 {
451            write_compact_nullable_string(buf, self.value.as_ref())?;
452        } else {
453            write_nullable_string(buf, self.value.as_ref())?;
454        }
455        write_bool(buf, self.read_only);
456        write_i8(buf, self.config_source);
457        write_bool(buf, self.is_sensitive);
458        if version >= 4 {
459            write_compact_array_length(buf, self.synonyms.len() as i32);
460            for el in &self.synonyms {
461                el.write(buf, version)?;
462            }
463        } else {
464            write_array_length(buf, self.synonyms.len() as i32);
465            for el in &self.synonyms {
466                el.write(buf, version)?;
467            }
468        }
469        if version >= 3 {
470            write_i8(buf, self.config_type);
471        } else if self.config_type != 0i8 {
472            return Err(UnsupportedFieldVersion::new(32, "config_type", version).into());
473        }
474        if version >= 3 {
475            if version >= 4 {
476                write_compact_nullable_string(buf, self.documentation.as_ref())?;
477            } else {
478                write_nullable_string(buf, self.documentation.as_ref())?;
479            }
480        } else if self.documentation != None {
481            return Err(UnsupportedFieldVersion::new(32, "documentation", version).into());
482        }
483        if version >= 4 {
484            let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
485            all_tags.sort_by_key(|f| f.tag);
486            write_tagged_fields(buf, &all_tags)?;
487        }
488        Ok(())
489    }
490    pub fn encoded_len(&self, version: i16) -> Result<usize> {
491        let mut len: usize = 0;
492        if version >= 4 {
493            len += compact_string_len(&self.name)?;
494        } else {
495            len += string_len(&self.name)?;
496        }
497        if version >= 4 {
498            len += compact_nullable_string_len(self.value.as_ref())?;
499        } else {
500            len += nullable_string_len(self.value.as_ref())?;
501        }
502        len += 1;
503        len += 1;
504        len += 1;
505        if version >= 4 {
506            len += compact_array_length_len(self.synonyms.len() as i32);
507            for el in &self.synonyms {
508                len += el.encoded_len(version)?;
509            }
510        } else {
511            len += array_length_len();
512            for el in &self.synonyms {
513                len += el.encoded_len(version)?;
514            }
515        }
516        if version >= 3 {
517            len += 1;
518        } else if self.config_type != 0i8 {
519            return Err(UnsupportedFieldVersion::new(32, "config_type", version).into());
520        }
521        if version >= 3 {
522            if version >= 4 {
523                len += compact_nullable_string_len(self.documentation.as_ref())?;
524            } else {
525                len += nullable_string_len(self.documentation.as_ref())?;
526            }
527        } else if self.documentation != None {
528            return Err(UnsupportedFieldVersion::new(32, "documentation", version).into());
529        }
530        if version >= 4 {
531            let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
532            all_tags.sort_by_key(|f| f.tag);
533            len += tagged_fields_len(&all_tags)?;
534        }
535        Ok(len)
536    }
537}
538#[derive(Debug, Clone, PartialEq)]
539pub struct DescribeConfigsSynonym {
540    /// The synonym name.
541    pub name: KafkaString,
542    /// The synonym value.
543    pub value: Option<KafkaString>,
544    /// The synonym source.
545    pub source: i8,
546    pub _unknown_tagged_fields: Vec<RawTaggedField>,
547}
548impl Default for DescribeConfigsSynonym {
549    fn default() -> Self {
550        Self {
551            name: KafkaString::default(),
552            value: None,
553            source: 0_i8,
554            _unknown_tagged_fields: Vec::new(),
555        }
556    }
557}
558impl DescribeConfigsSynonym {
559    pub fn with_name(mut self, value: KafkaString) -> Self {
560        self.name = value;
561        self
562    }
563    pub fn with_value(mut self, value: Option<KafkaString>) -> Self {
564        self.value = value;
565        self
566    }
567    pub fn with_source(mut self, value: i8) -> Self {
568        self.source = value;
569        self
570    }
571    pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
572        let name;
573        let value;
574        let source;
575        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
576        if version >= 4 {
577            name = read_compact_string(buf)?;
578        } else {
579            name = read_string(buf)?;
580        }
581        if version >= 4 {
582            value = read_compact_nullable_string(buf)?;
583        } else {
584            value = read_nullable_string(buf)?;
585        }
586        source = read_i8(buf)?;
587        if version >= 4 {
588            let tagged_fields = read_tagged_fields(buf)?;
589            for field in &tagged_fields {
590                match field.tag {
591                    _ => {
592                        _unknown_tagged_fields.push(field.clone());
593                    },
594                }
595            }
596        }
597        Ok(Self {
598            name,
599            value,
600            source,
601            _unknown_tagged_fields,
602        })
603    }
604    pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
605        if version >= 4 {
606            write_compact_string(buf, &self.name)?;
607        } else {
608            write_string(buf, &self.name)?;
609        }
610        if version >= 4 {
611            write_compact_nullable_string(buf, self.value.as_ref())?;
612        } else {
613            write_nullable_string(buf, self.value.as_ref())?;
614        }
615        write_i8(buf, self.source);
616        if version >= 4 {
617            let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
618            all_tags.sort_by_key(|f| f.tag);
619            write_tagged_fields(buf, &all_tags)?;
620        }
621        Ok(())
622    }
623    pub fn encoded_len(&self, version: i16) -> Result<usize> {
624        let mut len: usize = 0;
625        if version >= 4 {
626            len += compact_string_len(&self.name)?;
627        } else {
628            len += string_len(&self.name)?;
629        }
630        if version >= 4 {
631            len += compact_nullable_string_len(self.value.as_ref())?;
632        } else {
633            len += nullable_string_len(self.value.as_ref())?;
634        }
635        len += 1;
636        if version >= 4 {
637            let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
638            all_tags.sort_by_key(|f| f.tag);
639            len += tagged_fields_len(&all_tags)?;
640        }
641        Ok(len)
642    }
643}