Skip to main content

crabka_protocol/opt/rustwide/workdir/generated/
DeleteAclsResponse.borrowed.rs

1// AUTO-GENERATED by crabka-protocol-codegen against a9ce3221537b8653448750697915607dc7936cf3. Do not edit.
2
3use bytes::BufMut;
4
5use crate::primitives::fixed::{get_i16, get_i32, get_i8, put_i16, put_i32, put_i8};
6use crate::primitives::string_bytes::{
7    compact_nullable_string_len, compact_string_len, nullable_string_len,
8    put_compact_nullable_string, put_compact_string, put_nullable_string, put_string,
9    string_len,
10};
11use crate::primitives::string_bytes_borrowed::{
12    get_compact_nullable_string_borrowed, get_compact_string_borrowed,
13    get_nullable_string_borrowed, get_string_borrowed,
14};
15use crate::tagged_fields::{read_tagged_fields, tagged_fields_len, WriteTaggedFields};
16use crate::{DecodeBorrow, Encode, ProtocolError, UnknownTaggedFields};
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
23#[inline]
24fn is_flexible(version: i16) -> bool { version >= FLEXIBLE_MIN }
25
26#[derive(Debug, Clone, PartialEq, Eq)]
27pub struct DeleteAclsResponse<'a> {
28    pub throttle_time_ms: i32,
29    pub filter_results: Vec<DeleteAclsFilterResult<'a>>,
30    pub unknown_tagged_fields: UnknownTaggedFields,
31}
32
33impl<'a> Default for DeleteAclsResponse<'a> {
34    fn default() -> Self {
35        Self {
36            throttle_time_ms: 0i32,
37            filter_results: Vec::new(),
38            unknown_tagged_fields: Default::default(),
39        }
40    }
41}
42
43impl<'a> DeleteAclsResponse<'a> {
44    pub fn to_owned(&self) -> crate::owned::delete_acls_response::DeleteAclsResponse {
45        crate::owned::delete_acls_response::DeleteAclsResponse {
46            throttle_time_ms: (self.throttle_time_ms),
47            filter_results: (self.filter_results).iter().map(|it| it.to_owned()).collect(),
48            unknown_tagged_fields: self.unknown_tagged_fields.clone(),
49        }
50    }
51}
52
53impl<'a> Encode for DeleteAclsResponse<'a> {
54    fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
55        if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
56            return Err(ProtocolError::UnsupportedVersion { api_key: API_KEY, version });
57        }
58        let flex = is_flexible(version);
59        if version >= 0 { put_i32(buf, self.throttle_time_ms) }
60        if version >= 0 { { crate::primitives::array::put_array_len(buf, (self.filter_results).len(), flex); for it in &self.filter_results { it.encode(buf, version)?; } } }
61        if flex {
62            let tagged = WriteTaggedFields::new();
63            tagged.write(buf, &self.unknown_tagged_fields);
64        }
65        Ok(())
66    }
67    fn encoded_len(&self, version: i16) -> usize {
68        let flex = is_flexible(version);
69        let mut n: usize = 0;
70        if version >= 0 { n += 4; }
71        if version >= 0 { n += { let prefix = crate::primitives::array::array_len_prefix_len((self.filter_results).len(), flex); let body: usize = (self.filter_results).iter().map(|it| it.encoded_len(version)).sum(); prefix + body }; }
72        if flex {
73            let known_pairs: Vec<(u32, usize)> = Vec::new();
74            n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
75        }
76        n
77    }
78}
79
80impl<'de> DecodeBorrow<'de> for DeleteAclsResponse<'de> {
81    fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
82        if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
83            return Err(ProtocolError::UnsupportedVersion { api_key: API_KEY, version });
84        }
85        let flex = is_flexible(version);
86        let mut out = Self::default();
87        if version >= 0 { out.throttle_time_ms = get_i32(buf)?; }
88        if version >= 0 { out.filter_results = { let n = crate::primitives::array::get_array_len(buf, flex)?; let mut v = Vec::with_capacity(n); for _ in 0..n { v.push(DeleteAclsFilterResult::decode_borrow(buf, version)?); } v }; }
89        if flex {
90            out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| {
91                Ok(false)
92            })?;
93        }
94        Ok(out)
95    }
96}
97
98#[derive(Debug, Clone, PartialEq, Eq)]
99pub struct DeleteAclsFilterResult<'a> {
100    pub error_code: i16,
101    pub error_message: Option<&'a str>,
102    pub matching_acls: Vec<DeleteAclsMatchingAcl<'a>>,
103    pub unknown_tagged_fields: UnknownTaggedFields,
104}
105
106impl<'a> Default for DeleteAclsFilterResult<'a> {
107    fn default() -> Self {
108        Self {
109            error_code: 0i16,
110            error_message: None,
111            matching_acls: Vec::new(),
112            unknown_tagged_fields: Default::default(),
113        }
114    }
115}
116
117impl<'a> DeleteAclsFilterResult<'a> {
118    pub fn to_owned(&self) -> crate::owned::delete_acls_response::DeleteAclsFilterResult {
119        crate::owned::delete_acls_response::DeleteAclsFilterResult {
120            error_code: (self.error_code),
121            error_message: (self.error_message).map(|s| s.to_string()),
122            matching_acls: (self.matching_acls).iter().map(|it| it.to_owned()).collect(),
123            unknown_tagged_fields: self.unknown_tagged_fields.clone(),
124        }
125    }
126}
127
128impl<'a> Encode for DeleteAclsFilterResult<'a> {
129    fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
130        let flex = version >= 2;
131        if version >= 0 { put_i16(buf, self.error_code) }
132        if version >= 0 { if flex { put_compact_nullable_string(buf, self.error_message) } else { put_nullable_string(buf, self.error_message) } }
133        if version >= 0 { { crate::primitives::array::put_array_len(buf, (self.matching_acls).len(), flex); for it in &self.matching_acls { it.encode(buf, version)?; } } }
134        if flex {
135            let tagged = WriteTaggedFields::new();
136            tagged.write(buf, &self.unknown_tagged_fields);
137        }
138        Ok(())
139    }
140    fn encoded_len(&self, version: i16) -> usize {
141        let flex = version >= 2;
142        let mut n: usize = 0;
143        if version >= 0 { n += 2; }
144        if version >= 0 { n += if flex { compact_nullable_string_len(self.error_message) } else { nullable_string_len(self.error_message) }; }
145        if version >= 0 { n += { let prefix = crate::primitives::array::array_len_prefix_len((self.matching_acls).len(), flex); let body: usize = (self.matching_acls).iter().map(|it| it.encoded_len(version)).sum(); prefix + body }; }
146        if flex {
147            let known_pairs: Vec<(u32, usize)> = Vec::new();
148            n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
149        }
150        n
151    }
152}
153
154impl<'de> DecodeBorrow<'de> for DeleteAclsFilterResult<'de> {
155    fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
156        let flex = version >= 2;
157        let mut out = Self::default();
158        if version >= 0 { out.error_code = get_i16(buf)?; }
159        if version >= 0 { out.error_message = if flex { get_compact_nullable_string_borrowed(buf)? } else { get_nullable_string_borrowed(buf)? }; }
160        if version >= 0 { out.matching_acls = { let n = crate::primitives::array::get_array_len(buf, flex)?; let mut v = Vec::with_capacity(n); for _ in 0..n { v.push(DeleteAclsMatchingAcl::decode_borrow(buf, version)?); } v }; }
161        if flex {
162            out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| {
163                Ok(false)
164            })?;
165        }
166        Ok(out)
167    }
168}
169
170#[derive(Debug, Clone, PartialEq, Eq)]
171pub struct DeleteAclsMatchingAcl<'a> {
172    pub error_code: i16,
173    pub error_message: Option<&'a str>,
174    pub resource_type: i8,
175    pub resource_name: &'a str,
176    pub pattern_type: i8,
177    pub principal: &'a str,
178    pub host: &'a str,
179    pub operation: i8,
180    pub permission_type: i8,
181    pub unknown_tagged_fields: UnknownTaggedFields,
182}
183
184impl<'a> Default for DeleteAclsMatchingAcl<'a> {
185    fn default() -> Self {
186        Self {
187            error_code: 0i16,
188            error_message: None,
189            resource_type: 0i8,
190            resource_name: "",
191            pattern_type: 3i8,
192            principal: "",
193            host: "",
194            operation: 0i8,
195            permission_type: 0i8,
196            unknown_tagged_fields: Default::default(),
197        }
198    }
199}
200
201impl<'a> DeleteAclsMatchingAcl<'a> {
202    pub fn to_owned(&self) -> crate::owned::delete_acls_response::DeleteAclsMatchingAcl {
203        crate::owned::delete_acls_response::DeleteAclsMatchingAcl {
204            error_code: (self.error_code),
205            error_message: (self.error_message).map(|s| s.to_string()),
206            resource_type: (self.resource_type),
207            resource_name: (self.resource_name).to_string(),
208            pattern_type: (self.pattern_type),
209            principal: (self.principal).to_string(),
210            host: (self.host).to_string(),
211            operation: (self.operation),
212            permission_type: (self.permission_type),
213            unknown_tagged_fields: self.unknown_tagged_fields.clone(),
214        }
215    }
216}
217
218impl<'a> Encode for DeleteAclsMatchingAcl<'a> {
219    fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
220        let flex = version >= 2;
221        if version >= 0 { put_i16(buf, self.error_code) }
222        if version >= 0 { if flex { put_compact_nullable_string(buf, self.error_message) } else { put_nullable_string(buf, self.error_message) } }
223        if version >= 0 { put_i8(buf, self.resource_type) }
224        if version >= 0 { if flex { put_compact_string(buf, self.resource_name) } else { put_string(buf, self.resource_name) } }
225        if version >= 1 { put_i8(buf, self.pattern_type) }
226        if version >= 0 { if flex { put_compact_string(buf, self.principal) } else { put_string(buf, self.principal) } }
227        if version >= 0 { if flex { put_compact_string(buf, self.host) } else { put_string(buf, self.host) } }
228        if version >= 0 { put_i8(buf, self.operation) }
229        if version >= 0 { put_i8(buf, self.permission_type) }
230        if flex {
231            let tagged = WriteTaggedFields::new();
232            tagged.write(buf, &self.unknown_tagged_fields);
233        }
234        Ok(())
235    }
236    fn encoded_len(&self, version: i16) -> usize {
237        let flex = version >= 2;
238        let mut n: usize = 0;
239        if version >= 0 { n += 2; }
240        if version >= 0 { n += if flex { compact_nullable_string_len(self.error_message) } else { nullable_string_len(self.error_message) }; }
241        if version >= 0 { n += 1; }
242        if version >= 0 { n += if flex { compact_string_len(self.resource_name) } else { string_len(self.resource_name) }; }
243        if version >= 1 { n += 1; }
244        if version >= 0 { n += if flex { compact_string_len(self.principal) } else { string_len(self.principal) }; }
245        if version >= 0 { n += if flex { compact_string_len(self.host) } else { string_len(self.host) }; }
246        if version >= 0 { n += 1; }
247        if version >= 0 { n += 1; }
248        if flex {
249            let known_pairs: Vec<(u32, usize)> = Vec::new();
250            n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
251        }
252        n
253    }
254}
255
256impl<'de> DecodeBorrow<'de> for DeleteAclsMatchingAcl<'de> {
257    fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
258        let flex = version >= 2;
259        let mut out = Self::default();
260        if version >= 0 { out.error_code = get_i16(buf)?; }
261        if version >= 0 { out.error_message = if flex { get_compact_nullable_string_borrowed(buf)? } else { get_nullable_string_borrowed(buf)? }; }
262        if version >= 0 { out.resource_type = get_i8(buf)?; }
263        if version >= 0 { out.resource_name = if flex { get_compact_string_borrowed(buf)? } else { get_string_borrowed(buf)? }; }
264        if version >= 1 { out.pattern_type = get_i8(buf)?; }
265        if version >= 0 { out.principal = if flex { get_compact_string_borrowed(buf)? } else { get_string_borrowed(buf)? }; }
266        if version >= 0 { out.host = if flex { get_compact_string_borrowed(buf)? } else { get_string_borrowed(buf)? }; }
267        if version >= 0 { out.operation = get_i8(buf)?; }
268        if version >= 0 { out.permission_type = get_i8(buf)?; }
269        if flex {
270            out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| {
271                Ok(false)
272            })?;
273        }
274        Ok(out)
275    }
276}