Skip to main content

kacrab_protocol/generated/
controller_registration_response.rs

1//! Generated from ControllerRegistrationResponse.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 ControllerRegistrationResponseData {
17    /// Duration in milliseconds for which the request was throttled due to a quota violation, or
18    /// zero if the request did not violate any quota.
19    pub throttle_time_ms: i32,
20    /// The response error code.
21    pub error_code: i16,
22    /// The response error message, or null if there was no error.
23    pub error_message: Option<KafkaString>,
24    pub _unknown_tagged_fields: Vec<RawTaggedField>,
25}
26impl Default for ControllerRegistrationResponseData {
27    fn default() -> Self {
28        Self {
29            throttle_time_ms: 0_i32,
30            error_code: 0_i16,
31            error_message: None,
32            _unknown_tagged_fields: Vec::new(),
33        }
34    }
35}
36impl ControllerRegistrationResponseData {
37    pub fn with_throttle_time_ms(mut self, value: i32) -> Self {
38        self.throttle_time_ms = value;
39        self
40    }
41    pub fn with_error_code(mut self, value: i16) -> Self {
42        self.error_code = value;
43        self
44    }
45    pub fn with_error_message(mut self, value: Option<KafkaString>) -> Self {
46        self.error_message = value;
47        self
48    }
49    pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
50        if version < 0 || version > 0 {
51            return Err(UnsupportedVersion::new(70, version).into());
52        }
53        let throttle_time_ms;
54        let error_code;
55        let error_message;
56        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
57        throttle_time_ms = read_i32(buf)?;
58        error_code = read_i16(buf)?;
59        error_message = read_compact_nullable_string(buf)?;
60        let tagged_fields = read_tagged_fields(buf)?;
61        for field in &tagged_fields {
62            match field.tag {
63                _ => {
64                    _unknown_tagged_fields.push(field.clone());
65                },
66            }
67        }
68        Ok(Self {
69            throttle_time_ms,
70            error_code,
71            error_message,
72            _unknown_tagged_fields,
73        })
74    }
75    pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
76        if version < 0 || version > 0 {
77            return Err(UnsupportedVersion::new(70, version).into());
78        }
79        write_i32(buf, self.throttle_time_ms);
80        write_i16(buf, self.error_code);
81        write_compact_nullable_string(buf, self.error_message.as_ref())?;
82        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
83        all_tags.sort_by_key(|f| f.tag);
84        write_tagged_fields(buf, &all_tags)?;
85        Ok(())
86    }
87    pub fn encoded_len(&self, version: i16) -> Result<usize> {
88        if version < 0 || version > 0 {
89            return Err(UnsupportedVersion::new(70, version).into());
90        }
91        let mut len: usize = 0;
92        len += 4;
93        len += 2;
94        len += compact_nullable_string_len(self.error_message.as_ref())?;
95        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
96        all_tags.sort_by_key(|f| f.tag);
97        len += tagged_fields_len(&all_tags)?;
98        Ok(len)
99    }
100}