crabka_protocol/opt/rustwide/workdir/generated/
DescribeConfigsResponse.owned.rs1use crate::primitives::fixed::{
4 get_bool, get_i8, get_i16, get_i32, put_bool, put_i8, put_i16, put_i32,
5};
6use crate::primitives::string_bytes::{
7 compact_nullable_string_len, compact_string_len, get_compact_nullable_string_owned,
8 get_compact_string_owned, get_nullable_string_owned, get_string_owned, nullable_string_len,
9 put_compact_nullable_string, put_compact_string, put_nullable_string, put_string, string_len,
10};
11use crate::tagged_fields::{WriteTaggedFields, read_tagged_fields, tagged_fields_len};
12use crate::{Decode, Encode, ProtocolError, UnknownTaggedFields};
13use bytes::{Buf, BufMut};
14pub const API_KEY: i16 = 32;
15pub const MIN_VERSION: i16 = 1;
16pub const MAX_VERSION: i16 = 4;
17pub const FLEXIBLE_MIN: i16 = 4;
18#[inline]
19fn is_flexible(version: i16) -> bool {
20 version >= FLEXIBLE_MIN
21}
22#[derive(Debug, Clone, PartialEq, Eq, Default)]
23pub struct DescribeConfigsResponse {
24 pub throttle_time_ms: i32,
25 pub results: Vec<DescribeConfigsResult>,
26 pub unknown_tagged_fields: UnknownTaggedFields,
27}
28impl Encode for DescribeConfigsResponse {
29 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
30 if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
31 return Err(ProtocolError::UnsupportedVersion {
32 api_key: API_KEY,
33 version,
34 });
35 }
36 let flex = is_flexible(version);
37 if version >= 0 {
38 put_i32(buf, self.throttle_time_ms);
39 }
40 if version >= 0 {
41 {
42 crate::primitives::array::put_array_len(buf, (self.results).len(), flex);
43 for it in &self.results {
44 it.encode(buf, version)?;
45 }
46 }
47 }
48 if flex {
49 let tagged = WriteTaggedFields::new();
50 tagged.write(buf, &self.unknown_tagged_fields);
51 }
52 Ok(())
53 }
54 fn encoded_len(&self, version: i16) -> usize {
55 let flex = is_flexible(version);
56 let mut n: usize = 0;
57 if version >= 0 {
58 n += 4;
59 }
60 if version >= 0 {
61 n += {
62 let prefix =
63 crate::primitives::array::array_len_prefix_len((self.results).len(), flex);
64 let body: usize = (self.results)
65 .iter()
66 .map(|it| it.encoded_len(version))
67 .sum();
68 prefix + body
69 };
70 }
71 if flex {
72 let known_pairs: Vec<(u32, usize)> = Vec::new();
73 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
74 }
75 n
76 }
77}
78impl Decode<'_> for DescribeConfigsResponse {
79 fn decode<B: Buf>(buf: &mut B, version: i16) -> Result<Self, ProtocolError> {
80 if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
81 return Err(ProtocolError::UnsupportedVersion {
82 api_key: API_KEY,
83 version,
84 });
85 }
86 let flex = is_flexible(version);
87 let mut out = Self::default();
88 if version >= 0 {
89 out.throttle_time_ms = get_i32(buf)?;
90 }
91 if version >= 0 {
92 out.results = {
93 let n = crate::primitives::array::get_array_len(buf, flex)?;
94 let mut v = Vec::with_capacity(n);
95 for _ in 0..n {
96 v.push(DescribeConfigsResult::decode(buf, version)?);
97 }
98 v
99 };
100 }
101 if flex {
102 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
103 }
104 Ok(out)
105 }
106}
107#[cfg(test)]
108impl DescribeConfigsResponse {
109 #[must_use]
110 pub fn populated(version: i16) -> Self {
111 let mut m = Self::default();
112 if version >= 0 {
113 m.throttle_time_ms = 1i32;
114 }
115 if version >= 0 {
116 m.results = vec![DescribeConfigsResult::populated(version)];
117 }
118 m
119 }
120}
121#[derive(Debug, Clone, PartialEq, Eq, Default)]
122pub struct DescribeConfigsResult {
123 pub error_code: i16,
124 pub error_message: Option<String>,
125 pub resource_type: i8,
126 pub resource_name: String,
127 pub configs: Vec<DescribeConfigsResourceResult>,
128 pub unknown_tagged_fields: UnknownTaggedFields,
129}
130impl Encode for DescribeConfigsResult {
131 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
132 let flex = version >= 4;
133 if version >= 0 {
134 put_i16(buf, self.error_code);
135 }
136 if version >= 0 {
137 if flex {
138 put_compact_nullable_string(buf, self.error_message.as_deref());
139 } else {
140 put_nullable_string(buf, self.error_message.as_deref());
141 }
142 }
143 if version >= 0 {
144 put_i8(buf, self.resource_type);
145 }
146 if version >= 0 {
147 if flex {
148 put_compact_string(buf, &self.resource_name);
149 } else {
150 put_string(buf, &self.resource_name);
151 }
152 }
153 if version >= 0 {
154 {
155 crate::primitives::array::put_array_len(buf, (self.configs).len(), flex);
156 for it in &self.configs {
157 it.encode(buf, version)?;
158 }
159 }
160 }
161 if flex {
162 let tagged = WriteTaggedFields::new();
163 tagged.write(buf, &self.unknown_tagged_fields);
164 }
165 Ok(())
166 }
167 fn encoded_len(&self, version: i16) -> usize {
168 let flex = version >= 4;
169 let mut n: usize = 0;
170 if version >= 0 {
171 n += 2;
172 }
173 if version >= 0 {
174 n += if flex {
175 compact_nullable_string_len(self.error_message.as_deref())
176 } else {
177 nullable_string_len(self.error_message.as_deref())
178 };
179 }
180 if version >= 0 {
181 n += 1;
182 }
183 if version >= 0 {
184 n += if flex {
185 compact_string_len(&self.resource_name)
186 } else {
187 string_len(&self.resource_name)
188 };
189 }
190 if version >= 0 {
191 n += {
192 let prefix =
193 crate::primitives::array::array_len_prefix_len((self.configs).len(), flex);
194 let body: usize = (self.configs)
195 .iter()
196 .map(|it| it.encoded_len(version))
197 .sum();
198 prefix + body
199 };
200 }
201 if flex {
202 let known_pairs: Vec<(u32, usize)> = Vec::new();
203 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
204 }
205 n
206 }
207}
208impl Decode<'_> for DescribeConfigsResult {
209 fn decode<B: Buf>(buf: &mut B, version: i16) -> Result<Self, ProtocolError> {
210 let flex = version >= 4;
211 let mut out = Self::default();
212 if version >= 0 {
213 out.error_code = get_i16(buf)?;
214 }
215 if version >= 0 {
216 out.error_message = if flex {
217 get_compact_nullable_string_owned(buf)?
218 } else {
219 get_nullable_string_owned(buf)?
220 };
221 }
222 if version >= 0 {
223 out.resource_type = get_i8(buf)?;
224 }
225 if version >= 0 {
226 out.resource_name = if flex {
227 get_compact_string_owned(buf)?
228 } else {
229 get_string_owned(buf)?
230 };
231 }
232 if version >= 0 {
233 out.configs = {
234 let n = crate::primitives::array::get_array_len(buf, flex)?;
235 let mut v = Vec::with_capacity(n);
236 for _ in 0..n {
237 v.push(DescribeConfigsResourceResult::decode(buf, version)?);
238 }
239 v
240 };
241 }
242 if flex {
243 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
244 }
245 Ok(out)
246 }
247}
248#[cfg(test)]
249impl DescribeConfigsResult {
250 #[must_use]
251 pub fn populated(version: i16) -> Self {
252 let mut m = Self::default();
253 if version >= 0 {
254 m.error_code = 1i16;
255 }
256 if version >= 0 {
257 m.error_message = Some("x".to_string());
258 }
259 if version >= 0 {
260 m.resource_type = 1i8;
261 }
262 if version >= 0 {
263 m.resource_name = "x".to_string();
264 }
265 if version >= 0 {
266 m.configs = vec![DescribeConfigsResourceResult::populated(version)];
267 }
268 m
269 }
270}
271#[derive(Debug, Clone, PartialEq, Eq)]
272pub struct DescribeConfigsResourceResult {
273 pub name: String,
274 pub value: Option<String>,
275 pub read_only: bool,
276 pub config_source: i8,
277 pub is_sensitive: bool,
278 pub synonyms: Vec<DescribeConfigsSynonym>,
279 pub config_type: i8,
280 pub documentation: Option<String>,
281 pub unknown_tagged_fields: UnknownTaggedFields,
282}
283impl Default for DescribeConfigsResourceResult {
284 fn default() -> Self {
285 Self {
286 name: String::new(),
287 value: None,
288 read_only: false,
289 config_source: -1i8,
290 is_sensitive: false,
291 synonyms: Vec::new(),
292 config_type: 0i8,
293 documentation: None,
294 unknown_tagged_fields: Default::default(),
295 }
296 }
297}
298impl Encode for DescribeConfigsResourceResult {
299 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
300 let flex = version >= 4;
301 if version >= 0 {
302 if flex {
303 put_compact_string(buf, &self.name);
304 } else {
305 put_string(buf, &self.name);
306 }
307 }
308 if version >= 0 {
309 if flex {
310 put_compact_nullable_string(buf, self.value.as_deref());
311 } else {
312 put_nullable_string(buf, self.value.as_deref());
313 }
314 }
315 if version >= 0 {
316 put_bool(buf, self.read_only);
317 }
318 if version >= 1 {
319 put_i8(buf, self.config_source);
320 }
321 if version >= 0 {
322 put_bool(buf, self.is_sensitive);
323 }
324 if version >= 1 {
325 {
326 crate::primitives::array::put_array_len(buf, (self.synonyms).len(), flex);
327 for it in &self.synonyms {
328 it.encode(buf, version)?;
329 }
330 }
331 }
332 if version >= 3 {
333 put_i8(buf, self.config_type);
334 }
335 if version >= 3 {
336 if flex {
337 put_compact_nullable_string(buf, self.documentation.as_deref());
338 } else {
339 put_nullable_string(buf, self.documentation.as_deref());
340 }
341 }
342 if flex {
343 let tagged = WriteTaggedFields::new();
344 tagged.write(buf, &self.unknown_tagged_fields);
345 }
346 Ok(())
347 }
348 fn encoded_len(&self, version: i16) -> usize {
349 let flex = version >= 4;
350 let mut n: usize = 0;
351 if version >= 0 {
352 n += if flex {
353 compact_string_len(&self.name)
354 } else {
355 string_len(&self.name)
356 };
357 }
358 if version >= 0 {
359 n += if flex {
360 compact_nullable_string_len(self.value.as_deref())
361 } else {
362 nullable_string_len(self.value.as_deref())
363 };
364 }
365 if version >= 0 {
366 n += 1;
367 }
368 if version >= 1 {
369 n += 1;
370 }
371 if version >= 0 {
372 n += 1;
373 }
374 if version >= 1 {
375 n += {
376 let prefix =
377 crate::primitives::array::array_len_prefix_len((self.synonyms).len(), flex);
378 let body: usize = (self.synonyms)
379 .iter()
380 .map(|it| it.encoded_len(version))
381 .sum();
382 prefix + body
383 };
384 }
385 if version >= 3 {
386 n += 1;
387 }
388 if version >= 3 {
389 n += if flex {
390 compact_nullable_string_len(self.documentation.as_deref())
391 } else {
392 nullable_string_len(self.documentation.as_deref())
393 };
394 }
395 if flex {
396 let known_pairs: Vec<(u32, usize)> = Vec::new();
397 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
398 }
399 n
400 }
401}
402impl Decode<'_> for DescribeConfigsResourceResult {
403 fn decode<B: Buf>(buf: &mut B, version: i16) -> Result<Self, ProtocolError> {
404 let flex = version >= 4;
405 let mut out = Self::default();
406 if version >= 0 {
407 out.name = if flex {
408 get_compact_string_owned(buf)?
409 } else {
410 get_string_owned(buf)?
411 };
412 }
413 if version >= 0 {
414 out.value = if flex {
415 get_compact_nullable_string_owned(buf)?
416 } else {
417 get_nullable_string_owned(buf)?
418 };
419 }
420 if version >= 0 {
421 out.read_only = get_bool(buf)?;
422 }
423 if version >= 1 {
424 out.config_source = get_i8(buf)?;
425 }
426 if version >= 0 {
427 out.is_sensitive = get_bool(buf)?;
428 }
429 if version >= 1 {
430 out.synonyms = {
431 let n = crate::primitives::array::get_array_len(buf, flex)?;
432 let mut v = Vec::with_capacity(n);
433 for _ in 0..n {
434 v.push(DescribeConfigsSynonym::decode(buf, version)?);
435 }
436 v
437 };
438 }
439 if version >= 3 {
440 out.config_type = get_i8(buf)?;
441 }
442 if version >= 3 {
443 out.documentation = if flex {
444 get_compact_nullable_string_owned(buf)?
445 } else {
446 get_nullable_string_owned(buf)?
447 };
448 }
449 if flex {
450 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
451 }
452 Ok(out)
453 }
454}
455#[cfg(test)]
456impl DescribeConfigsResourceResult {
457 #[must_use]
458 pub fn populated(version: i16) -> Self {
459 let mut m = Self::default();
460 if version >= 0 {
461 m.name = "x".to_string();
462 }
463 if version >= 0 {
464 m.value = Some("x".to_string());
465 }
466 if version >= 0 {
467 m.read_only = true;
468 }
469 if version >= 1 {
470 m.config_source = 1i8;
471 }
472 if version >= 0 {
473 m.is_sensitive = true;
474 }
475 if version >= 1 {
476 m.synonyms = vec![DescribeConfigsSynonym::populated(version)];
477 }
478 if version >= 3 {
479 m.config_type = 1i8;
480 }
481 if version >= 3 {
482 m.documentation = Some("x".to_string());
483 }
484 m
485 }
486}
487#[derive(Debug, Clone, PartialEq, Eq, Default)]
488pub struct DescribeConfigsSynonym {
489 pub name: String,
490 pub value: Option<String>,
491 pub source: i8,
492 pub unknown_tagged_fields: UnknownTaggedFields,
493}
494impl Encode for DescribeConfigsSynonym {
495 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
496 let flex = version >= 4;
497 if version >= 1 {
498 if flex {
499 put_compact_string(buf, &self.name);
500 } else {
501 put_string(buf, &self.name);
502 }
503 }
504 if version >= 1 {
505 if flex {
506 put_compact_nullable_string(buf, self.value.as_deref());
507 } else {
508 put_nullable_string(buf, self.value.as_deref());
509 }
510 }
511 if version >= 1 {
512 put_i8(buf, self.source);
513 }
514 if flex {
515 let tagged = WriteTaggedFields::new();
516 tagged.write(buf, &self.unknown_tagged_fields);
517 }
518 Ok(())
519 }
520 fn encoded_len(&self, version: i16) -> usize {
521 let flex = version >= 4;
522 let mut n: usize = 0;
523 if version >= 1 {
524 n += if flex {
525 compact_string_len(&self.name)
526 } else {
527 string_len(&self.name)
528 };
529 }
530 if version >= 1 {
531 n += if flex {
532 compact_nullable_string_len(self.value.as_deref())
533 } else {
534 nullable_string_len(self.value.as_deref())
535 };
536 }
537 if version >= 1 {
538 n += 1;
539 }
540 if flex {
541 let known_pairs: Vec<(u32, usize)> = Vec::new();
542 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
543 }
544 n
545 }
546}
547impl Decode<'_> for DescribeConfigsSynonym {
548 fn decode<B: Buf>(buf: &mut B, version: i16) -> Result<Self, ProtocolError> {
549 let flex = version >= 4;
550 let mut out = Self::default();
551 if version >= 1 {
552 out.name = if flex {
553 get_compact_string_owned(buf)?
554 } else {
555 get_string_owned(buf)?
556 };
557 }
558 if version >= 1 {
559 out.value = if flex {
560 get_compact_nullable_string_owned(buf)?
561 } else {
562 get_nullable_string_owned(buf)?
563 };
564 }
565 if version >= 1 {
566 out.source = get_i8(buf)?;
567 }
568 if flex {
569 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
570 }
571 Ok(out)
572 }
573}
574#[cfg(test)]
575impl DescribeConfigsSynonym {
576 #[must_use]
577 pub fn populated(version: i16) -> Self {
578 let mut m = Self::default();
579 if version >= 1 {
580 m.name = "x".to_string();
581 }
582 if version >= 1 {
583 m.value = Some("x".to_string());
584 }
585 if version >= 1 {
586 m.source = 1i8;
587 }
588 m
589 }
590}
591#[must_use]
594#[allow(unused_comparisons)]
595pub fn default_json(version: i16) -> ::serde_json::Value {
596 let mut obj = ::serde_json::Map::new();
597 obj.insert("throttleTimeMs".to_string(), ::serde_json::json!(0));
598 obj.insert("results".to_string(), ::serde_json::Value::Array(vec![]));
599 ::serde_json::Value::Object(obj)
600}