Skip to main content

krabka_protocol/opt/rustwide/workdir/generated/
DeleteAclsResponse.owned.rs

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