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