kacrab_protocol/generated/
describe_client_quotas_request.rs1#![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 DescribeClientQuotasRequestData {
17 pub components: Vec<ComponentData>,
19 pub strict: bool,
21 pub _unknown_tagged_fields: Vec<RawTaggedField>,
22}
23impl Default for DescribeClientQuotasRequestData {
24 fn default() -> Self {
25 Self {
26 components: Vec::new(),
27 strict: false,
28 _unknown_tagged_fields: Vec::new(),
29 }
30 }
31}
32impl DescribeClientQuotasRequestData {
33 pub fn with_components(mut self, value: Vec<ComponentData>) -> Self {
34 self.components = value;
35 self
36 }
37 pub fn with_strict(mut self, value: bool) -> Self {
38 self.strict = value;
39 self
40 }
41 pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
42 if version < 0 || version > 1 {
43 return Err(UnsupportedVersion::new(48, version).into());
44 }
45 let components;
46 let strict;
47 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
48 if version >= 1 {
49 components = {
50 let len = read_compact_array_length(buf)?;
51 let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
52 for _ in 0..len {
53 arr.push(ComponentData::read(buf, version)?);
54 }
55 arr
56 };
57 } else {
58 components = {
59 let len = read_array_length(buf)?;
60 let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
61 for _ in 0..len {
62 arr.push(ComponentData::read(buf, version)?);
63 }
64 arr
65 };
66 }
67 strict = read_bool(buf)?;
68 if version >= 1 {
69 let tagged_fields = read_tagged_fields(buf)?;
70 for field in &tagged_fields {
71 match field.tag {
72 _ => {
73 _unknown_tagged_fields.push(field.clone());
74 },
75 }
76 }
77 }
78 Ok(Self {
79 components,
80 strict,
81 _unknown_tagged_fields,
82 })
83 }
84 pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
85 if version < 0 || version > 1 {
86 return Err(UnsupportedVersion::new(48, version).into());
87 }
88 if version >= 1 {
89 write_compact_array_length(buf, self.components.len() as i32);
90 for el in &self.components {
91 el.write(buf, version)?;
92 }
93 } else {
94 write_array_length(buf, self.components.len() as i32);
95 for el in &self.components {
96 el.write(buf, version)?;
97 }
98 }
99 write_bool(buf, self.strict);
100 if version >= 1 {
101 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
102 all_tags.sort_by_key(|f| f.tag);
103 write_tagged_fields(buf, &all_tags)?;
104 }
105 Ok(())
106 }
107 pub fn encoded_len(&self, version: i16) -> Result<usize> {
108 if version < 0 || version > 1 {
109 return Err(UnsupportedVersion::new(48, version).into());
110 }
111 let mut len: usize = 0;
112 if version >= 1 {
113 len += compact_array_length_len(self.components.len() as i32);
114 for el in &self.components {
115 len += el.encoded_len(version)?;
116 }
117 } else {
118 len += array_length_len();
119 for el in &self.components {
120 len += el.encoded_len(version)?;
121 }
122 }
123 len += 1;
124 if version >= 1 {
125 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
126 all_tags.sort_by_key(|f| f.tag);
127 len += tagged_fields_len(&all_tags)?;
128 }
129 Ok(len)
130 }
131}
132#[derive(Debug, Clone, PartialEq)]
133pub struct ComponentData {
134 pub entity_type: KafkaString,
136 pub match_type: i8,
138 pub r#match: Option<KafkaString>,
140 pub _unknown_tagged_fields: Vec<RawTaggedField>,
141}
142impl Default for ComponentData {
143 fn default() -> Self {
144 Self {
145 entity_type: KafkaString::default(),
146 match_type: 0_i8,
147 r#match: None,
148 _unknown_tagged_fields: Vec::new(),
149 }
150 }
151}
152impl ComponentData {
153 pub fn with_entity_type(mut self, value: KafkaString) -> Self {
154 self.entity_type = value;
155 self
156 }
157 pub fn with_match_type(mut self, value: i8) -> Self {
158 self.match_type = value;
159 self
160 }
161 pub fn with_match(mut self, value: Option<KafkaString>) -> Self {
162 self.r#match = value;
163 self
164 }
165 pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
166 let entity_type;
167 let match_type;
168 let r#match;
169 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
170 if version >= 1 {
171 entity_type = read_compact_string(buf)?;
172 } else {
173 entity_type = read_string(buf)?;
174 }
175 match_type = read_i8(buf)?;
176 if version >= 1 {
177 r#match = read_compact_nullable_string(buf)?;
178 } else {
179 r#match = read_nullable_string(buf)?;
180 }
181 if version >= 1 {
182 let tagged_fields = read_tagged_fields(buf)?;
183 for field in &tagged_fields {
184 match field.tag {
185 _ => {
186 _unknown_tagged_fields.push(field.clone());
187 },
188 }
189 }
190 }
191 Ok(Self {
192 entity_type,
193 match_type,
194 r#match,
195 _unknown_tagged_fields,
196 })
197 }
198 pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
199 if version >= 1 {
200 write_compact_string(buf, &self.entity_type)?;
201 } else {
202 write_string(buf, &self.entity_type)?;
203 }
204 write_i8(buf, self.match_type);
205 if version >= 1 {
206 write_compact_nullable_string(buf, self.r#match.as_ref())?;
207 } else {
208 write_nullable_string(buf, self.r#match.as_ref())?;
209 }
210 if version >= 1 {
211 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
212 all_tags.sort_by_key(|f| f.tag);
213 write_tagged_fields(buf, &all_tags)?;
214 }
215 Ok(())
216 }
217 pub fn encoded_len(&self, version: i16) -> Result<usize> {
218 let mut len: usize = 0;
219 if version >= 1 {
220 len += compact_string_len(&self.entity_type)?;
221 } else {
222 len += string_len(&self.entity_type)?;
223 }
224 len += 1;
225 if version >= 1 {
226 len += compact_nullable_string_len(self.r#match.as_ref())?;
227 } else {
228 len += nullable_string_len(self.r#match.as_ref())?;
229 }
230 if version >= 1 {
231 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
232 all_tags.sort_by_key(|f| f.tag);
233 len += tagged_fields_len(&all_tags)?;
234 }
235 Ok(len)
236 }
237}