krabka_protocol/opt/rustwide/workdir/generated/
DeleteShareGroupStateResponse.owned.rs1use bytes::{Buf, BufMut};
4
5use crate::{
6 Decode, Encode, ProtocolError, UnknownTaggedFields,
7 primitives::{
8 fixed::{get_i16, get_i32, put_i16, put_i32},
9 string_bytes::{
10 compact_nullable_string_len, get_compact_nullable_string_owned,
11 get_nullable_string_owned, nullable_string_len, put_compact_nullable_string,
12 put_nullable_string,
13 },
14 },
15 tagged_fields::{WriteTaggedFields, read_tagged_fields, tagged_fields_len},
16};
17pub const API_KEY: i16 = 86;
18pub const MIN_VERSION: i16 = 0;
19pub const MAX_VERSION: i16 = 0;
20pub const FLEXIBLE_MIN: i16 = 0;
21#[inline]
22#[must_use]
23pub fn is_flexible(version: i16) -> bool {
24 version >= FLEXIBLE_MIN
25}
26#[derive(Debug, Clone, PartialEq, Eq, Default)]
27pub struct DeleteShareGroupStateResponse {
28 pub results: Vec<DeleteStateResult>,
29 pub unknown_tagged_fields: UnknownTaggedFields,
30}
31impl Encode for DeleteShareGroupStateResponse {
32 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
33 if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
34 return Err(ProtocolError::UnsupportedVersion {
35 api_key: API_KEY,
36 version,
37 });
38 }
39 let flex = is_flexible(version);
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 += {
59 let prefix =
60 crate::primitives::array::array_len_prefix_len((self.results).len(), flex);
61 let body: usize = (self.results)
62 .iter()
63 .map(|it| it.encoded_len(version))
64 .sum();
65 prefix + body
66 };
67 }
68 if flex {
69 let known_pairs: Vec<(u32, usize)> = Vec::new();
70 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
71 }
72 n
73 }
74}
75impl Decode<'_> for DeleteShareGroupStateResponse {
76 fn decode<B: Buf>(buf: &mut B, version: i16) -> Result<Self, ProtocolError> {
77 if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
78 return Err(ProtocolError::UnsupportedVersion {
79 api_key: API_KEY,
80 version,
81 });
82 }
83 let flex = is_flexible(version);
84 let mut out = Self::default();
85 if version >= 0 {
86 out.results = {
87 let n = crate::primitives::array::get_array_len(buf, flex)?;
88 let mut v = Vec::with_capacity(n);
89 for _ in 0..n {
90 v.push(DeleteStateResult::decode(buf, version)?);
91 }
92 v
93 };
94 }
95 if flex {
96 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
97 }
98 Ok(out)
99 }
100}
101#[cfg(test)]
102impl DeleteShareGroupStateResponse {
103 #[must_use]
104 pub fn populated(version: i16) -> Self {
105 let mut m = Self::default();
106 if version >= 0 {
107 m.results = vec![DeleteStateResult::populated(version)];
108 }
109 m
110 }
111}
112#[derive(Debug, Clone, PartialEq, Eq, Default)]
113pub struct DeleteStateResult {
114 pub topic_id: crate::primitives::uuid::Uuid,
115 pub partitions: Vec<PartitionResult>,
116 pub unknown_tagged_fields: UnknownTaggedFields,
117}
118impl Encode for DeleteStateResult {
119 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
120 let flex = version >= 0;
121 if version >= 0 {
122 crate::primitives::uuid::put_uuid(buf, self.topic_id);
123 }
124 if version >= 0 {
125 {
126 crate::primitives::array::put_array_len(buf, (self.partitions).len(), flex);
127 for it in &self.partitions {
128 it.encode(buf, version)?;
129 }
130 };
131 }
132 if flex {
133 let tagged = WriteTaggedFields::new();
134 tagged.write(buf, &self.unknown_tagged_fields);
135 }
136 Ok(())
137 }
138 fn encoded_len(&self, version: i16) -> usize {
139 let flex = version >= 0;
140 let mut n: usize = 0;
141 if version >= 0 {
142 n += 16;
143 }
144 if version >= 0 {
145 n += {
146 let prefix =
147 crate::primitives::array::array_len_prefix_len((self.partitions).len(), flex);
148 let body: usize = (self.partitions)
149 .iter()
150 .map(|it| it.encoded_len(version))
151 .sum();
152 prefix + body
153 };
154 }
155 if flex {
156 let known_pairs: Vec<(u32, usize)> = Vec::new();
157 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
158 }
159 n
160 }
161}
162impl Decode<'_> for DeleteStateResult {
163 fn decode<B: Buf>(buf: &mut B, version: i16) -> Result<Self, ProtocolError> {
164 let flex = version >= 0;
165 let mut out = Self::default();
166 if version >= 0 {
167 out.topic_id = crate::primitives::uuid::get_uuid(buf)?;
168 }
169 if version >= 0 {
170 out.partitions = {
171 let n = crate::primitives::array::get_array_len(buf, flex)?;
172 let mut v = Vec::with_capacity(n);
173 for _ in 0..n {
174 v.push(PartitionResult::decode(buf, version)?);
175 }
176 v
177 };
178 }
179 if flex {
180 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
181 }
182 Ok(out)
183 }
184}
185#[cfg(test)]
186impl DeleteStateResult {
187 #[must_use]
188 pub fn populated(version: i16) -> Self {
189 let mut m = Self::default();
190 if version >= 0 {
191 m.topic_id = crate::primitives::uuid::Uuid([1u8; 16]);
192 }
193 if version >= 0 {
194 m.partitions = vec![PartitionResult::populated(version)];
195 }
196 m
197 }
198}
199#[derive(Debug, Clone, PartialEq, Eq, Default)]
200pub struct PartitionResult {
201 pub partition: i32,
202 pub error_code: i16,
203 pub error_message: Option<String>,
204 pub unknown_tagged_fields: UnknownTaggedFields,
205}
206impl Encode for PartitionResult {
207 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
208 let flex = version >= 0;
209 if version >= 0 {
210 put_i32(buf, self.partition);
211 }
212 if version >= 0 {
213 put_i16(buf, self.error_code);
214 }
215 if version >= 0 {
216 if flex {
217 let () = put_compact_nullable_string(buf, self.error_message.as_deref());
218 } else {
219 let () = put_nullable_string(buf, self.error_message.as_deref());
220 }
221 }
222 if flex {
223 let tagged = WriteTaggedFields::new();
224 tagged.write(buf, &self.unknown_tagged_fields);
225 }
226 Ok(())
227 }
228 fn encoded_len(&self, version: i16) -> usize {
229 let flex = version >= 0;
230 let mut n: usize = 0;
231 if version >= 0 {
232 n += 4;
233 }
234 if version >= 0 {
235 n += 2;
236 }
237 if version >= 0 {
238 n += if flex {
239 compact_nullable_string_len(self.error_message.as_deref())
240 } else {
241 nullable_string_len(self.error_message.as_deref())
242 };
243 }
244 if flex {
245 let known_pairs: Vec<(u32, usize)> = Vec::new();
246 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
247 }
248 n
249 }
250}
251impl Decode<'_> for PartitionResult {
252 fn decode<B: Buf>(buf: &mut B, version: i16) -> Result<Self, ProtocolError> {
253 let flex = version >= 0;
254 let mut out = Self::default();
255 if version >= 0 {
256 out.partition = get_i32(buf)?;
257 }
258 if version >= 0 {
259 out.error_code = get_i16(buf)?;
260 }
261 if version >= 0 {
262 out.error_message = if flex {
263 get_compact_nullable_string_owned(buf)?
264 } else {
265 get_nullable_string_owned(buf)?
266 };
267 }
268 if flex {
269 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
270 }
271 Ok(out)
272 }
273}
274#[cfg(test)]
275impl PartitionResult {
276 #[must_use]
277 pub fn populated(version: i16) -> Self {
278 let mut m = Self::default();
279 if version >= 0 {
280 m.partition = 1i32;
281 }
282 if version >= 0 {
283 m.error_code = 1i16;
284 }
285 if version >= 0 {
286 m.error_message = Some("x".to_string());
287 }
288 m
289 }
290}
291#[must_use]
294#[allow(unused_comparisons)]
295pub fn default_json(_version: i16) -> ::serde_json::Value {
296 let mut obj = ::serde_json::Map::new();
297 obj.insert("results".to_string(), ::serde_json::Value::Array(vec![]));
298 ::serde_json::Value::Object(obj)
299}