Skip to main content

kafka_protocol/messages/
describe_share_group_offsets_response.rs

1//! DescribeShareGroupOffsetsResponse
2//!
3//! See the schema for this message [here](https://github.com/apache/kafka/blob/trunk/clients/src/main/resources/common/message/DescribeShareGroupOffsetsResponse.json).
4// WARNING: the items of this module are generated and should not be edited directly
5#![allow(unused)]
6
7use std::borrow::Borrow;
8use std::collections::BTreeMap;
9
10use anyhow::{bail, Result};
11use bytes::Bytes;
12use uuid::Uuid;
13
14use crate::protocol::{
15    buf::{ByteBuf, ByteBufMut},
16    compute_unknown_tagged_fields_size, types, write_unknown_tagged_fields, Decodable, Decoder,
17    Encodable, Encoder, HeaderVersion, Message, StrBytes, VersionRange,
18};
19
20/// Valid versions: 0
21#[non_exhaustive]
22#[derive(Debug, Clone, PartialEq)]
23pub struct DescribeShareGroupOffsetsResponse {
24    /// The duration in milliseconds for which the request was throttled due to a quota violation, or zero if the request did not violate any quota.
25    ///
26    /// Supported API versions: 0
27    pub throttle_time_ms: i32,
28
29    /// The results for each group.
30    ///
31    /// Supported API versions: 0
32    pub groups: Vec<DescribeShareGroupOffsetsResponseGroup>,
33
34    /// Other tagged fields
35    pub unknown_tagged_fields: BTreeMap<i32, Bytes>,
36}
37
38impl DescribeShareGroupOffsetsResponse {
39    /// Sets `throttle_time_ms` to the passed value.
40    ///
41    /// The duration in milliseconds for which the request was throttled due to a quota violation, or zero if the request did not violate any quota.
42    ///
43    /// Supported API versions: 0
44    pub fn with_throttle_time_ms(mut self, value: i32) -> Self {
45        self.throttle_time_ms = value;
46        self
47    }
48    /// Sets `groups` to the passed value.
49    ///
50    /// The results for each group.
51    ///
52    /// Supported API versions: 0
53    pub fn with_groups(mut self, value: Vec<DescribeShareGroupOffsetsResponseGroup>) -> Self {
54        self.groups = value;
55        self
56    }
57    /// Sets unknown_tagged_fields to the passed value.
58    pub fn with_unknown_tagged_fields(mut self, value: BTreeMap<i32, Bytes>) -> Self {
59        self.unknown_tagged_fields = value;
60        self
61    }
62    /// Inserts an entry into unknown_tagged_fields.
63    pub fn with_unknown_tagged_field(mut self, key: i32, value: Bytes) -> Self {
64        self.unknown_tagged_fields.insert(key, value);
65        self
66    }
67}
68
69#[cfg(feature = "broker")]
70impl Encodable for DescribeShareGroupOffsetsResponse {
71    fn encode<B: ByteBufMut>(&self, buf: &mut B, version: i16) -> Result<()> {
72        if version != 0 {
73            bail!("specified version not supported by this message type");
74        }
75        types::Int32.encode(buf, &self.throttle_time_ms)?;
76        types::CompactArray(types::Struct { version }).encode(buf, &self.groups)?;
77        let num_tagged_fields = self.unknown_tagged_fields.len();
78        if num_tagged_fields > std::u32::MAX as usize {
79            bail!(
80                "Too many tagged fields to encode ({} fields)",
81                num_tagged_fields
82            );
83        }
84        types::UnsignedVarInt.encode(buf, num_tagged_fields as u32)?;
85
86        write_unknown_tagged_fields(buf, 0.., &self.unknown_tagged_fields)?;
87        Ok(())
88    }
89    fn compute_size(&self, version: i16) -> Result<usize> {
90        let mut total_size = 0;
91        total_size += types::Int32.compute_size(&self.throttle_time_ms)?;
92        total_size += types::CompactArray(types::Struct { version }).compute_size(&self.groups)?;
93        let num_tagged_fields = self.unknown_tagged_fields.len();
94        if num_tagged_fields > std::u32::MAX as usize {
95            bail!(
96                "Too many tagged fields to encode ({} fields)",
97                num_tagged_fields
98            );
99        }
100        total_size += types::UnsignedVarInt.compute_size(num_tagged_fields as u32)?;
101
102        total_size += compute_unknown_tagged_fields_size(&self.unknown_tagged_fields)?;
103        Ok(total_size)
104    }
105}
106
107#[cfg(feature = "client")]
108impl Decodable for DescribeShareGroupOffsetsResponse {
109    fn decode<B: ByteBuf>(buf: &mut B, version: i16) -> Result<Self> {
110        if version != 0 {
111            bail!("specified version not supported by this message type");
112        }
113        let throttle_time_ms = types::Int32.decode(buf)?;
114        let groups = types::CompactArray(types::Struct { version }).decode(buf)?;
115        let mut unknown_tagged_fields = BTreeMap::new();
116        let num_tagged_fields = types::UnsignedVarInt.decode(buf)?;
117        for _ in 0..num_tagged_fields {
118            let tag: u32 = types::UnsignedVarInt.decode(buf)?;
119            let size: u32 = types::UnsignedVarInt.decode(buf)?;
120            let unknown_value = buf.try_get_bytes(size as usize)?;
121            unknown_tagged_fields.insert(tag as i32, unknown_value);
122        }
123        Ok(Self {
124            throttle_time_ms,
125            groups,
126            unknown_tagged_fields,
127        })
128    }
129}
130
131impl Default for DescribeShareGroupOffsetsResponse {
132    fn default() -> Self {
133        Self {
134            throttle_time_ms: 0,
135            groups: Default::default(),
136            unknown_tagged_fields: BTreeMap::new(),
137        }
138    }
139}
140
141impl Message for DescribeShareGroupOffsetsResponse {
142    const VERSIONS: VersionRange = VersionRange { min: 0, max: 0 };
143    const DEPRECATED_VERSIONS: Option<VersionRange> = None;
144}
145
146/// Valid versions: 0
147#[non_exhaustive]
148#[derive(Debug, Clone, PartialEq)]
149pub struct DescribeShareGroupOffsetsResponseGroup {
150    /// The group identifier.
151    ///
152    /// Supported API versions: 0
153    pub group_id: super::GroupId,
154
155    /// The results for each topic.
156    ///
157    /// Supported API versions: 0
158    pub topics: Vec<DescribeShareGroupOffsetsResponseTopic>,
159
160    /// The group-level error code, or 0 if there was no error.
161    ///
162    /// Supported API versions: 0
163    pub error_code: i16,
164
165    /// The group-level error message, or null if there was no error.
166    ///
167    /// Supported API versions: 0
168    pub error_message: Option<StrBytes>,
169
170    /// Other tagged fields
171    pub unknown_tagged_fields: BTreeMap<i32, Bytes>,
172}
173
174impl DescribeShareGroupOffsetsResponseGroup {
175    /// Sets `group_id` to the passed value.
176    ///
177    /// The group identifier.
178    ///
179    /// Supported API versions: 0
180    pub fn with_group_id(mut self, value: super::GroupId) -> Self {
181        self.group_id = value;
182        self
183    }
184    /// Sets `topics` to the passed value.
185    ///
186    /// The results for each topic.
187    ///
188    /// Supported API versions: 0
189    pub fn with_topics(mut self, value: Vec<DescribeShareGroupOffsetsResponseTopic>) -> Self {
190        self.topics = value;
191        self
192    }
193    /// Sets `error_code` to the passed value.
194    ///
195    /// The group-level error code, or 0 if there was no error.
196    ///
197    /// Supported API versions: 0
198    pub fn with_error_code(mut self, value: i16) -> Self {
199        self.error_code = value;
200        self
201    }
202    /// Sets `error_message` to the passed value.
203    ///
204    /// The group-level error message, or null if there was no error.
205    ///
206    /// Supported API versions: 0
207    pub fn with_error_message(mut self, value: Option<StrBytes>) -> Self {
208        self.error_message = value;
209        self
210    }
211    /// Sets unknown_tagged_fields to the passed value.
212    pub fn with_unknown_tagged_fields(mut self, value: BTreeMap<i32, Bytes>) -> Self {
213        self.unknown_tagged_fields = value;
214        self
215    }
216    /// Inserts an entry into unknown_tagged_fields.
217    pub fn with_unknown_tagged_field(mut self, key: i32, value: Bytes) -> Self {
218        self.unknown_tagged_fields.insert(key, value);
219        self
220    }
221}
222
223#[cfg(feature = "broker")]
224impl Encodable for DescribeShareGroupOffsetsResponseGroup {
225    fn encode<B: ByteBufMut>(&self, buf: &mut B, version: i16) -> Result<()> {
226        if version != 0 {
227            bail!("specified version not supported by this message type");
228        }
229        types::CompactString.encode(buf, &self.group_id)?;
230        types::CompactArray(types::Struct { version }).encode(buf, &self.topics)?;
231        types::Int16.encode(buf, &self.error_code)?;
232        types::CompactString.encode(buf, &self.error_message)?;
233        let num_tagged_fields = self.unknown_tagged_fields.len();
234        if num_tagged_fields > std::u32::MAX as usize {
235            bail!(
236                "Too many tagged fields to encode ({} fields)",
237                num_tagged_fields
238            );
239        }
240        types::UnsignedVarInt.encode(buf, num_tagged_fields as u32)?;
241
242        write_unknown_tagged_fields(buf, 0.., &self.unknown_tagged_fields)?;
243        Ok(())
244    }
245    fn compute_size(&self, version: i16) -> Result<usize> {
246        let mut total_size = 0;
247        total_size += types::CompactString.compute_size(&self.group_id)?;
248        total_size += types::CompactArray(types::Struct { version }).compute_size(&self.topics)?;
249        total_size += types::Int16.compute_size(&self.error_code)?;
250        total_size += types::CompactString.compute_size(&self.error_message)?;
251        let num_tagged_fields = self.unknown_tagged_fields.len();
252        if num_tagged_fields > std::u32::MAX as usize {
253            bail!(
254                "Too many tagged fields to encode ({} fields)",
255                num_tagged_fields
256            );
257        }
258        total_size += types::UnsignedVarInt.compute_size(num_tagged_fields as u32)?;
259
260        total_size += compute_unknown_tagged_fields_size(&self.unknown_tagged_fields)?;
261        Ok(total_size)
262    }
263}
264
265#[cfg(feature = "client")]
266impl Decodable for DescribeShareGroupOffsetsResponseGroup {
267    fn decode<B: ByteBuf>(buf: &mut B, version: i16) -> Result<Self> {
268        if version != 0 {
269            bail!("specified version not supported by this message type");
270        }
271        let group_id = types::CompactString.decode(buf)?;
272        let topics = types::CompactArray(types::Struct { version }).decode(buf)?;
273        let error_code = types::Int16.decode(buf)?;
274        let error_message = types::CompactString.decode(buf)?;
275        let mut unknown_tagged_fields = BTreeMap::new();
276        let num_tagged_fields = types::UnsignedVarInt.decode(buf)?;
277        for _ in 0..num_tagged_fields {
278            let tag: u32 = types::UnsignedVarInt.decode(buf)?;
279            let size: u32 = types::UnsignedVarInt.decode(buf)?;
280            let unknown_value = buf.try_get_bytes(size as usize)?;
281            unknown_tagged_fields.insert(tag as i32, unknown_value);
282        }
283        Ok(Self {
284            group_id,
285            topics,
286            error_code,
287            error_message,
288            unknown_tagged_fields,
289        })
290    }
291}
292
293impl Default for DescribeShareGroupOffsetsResponseGroup {
294    fn default() -> Self {
295        Self {
296            group_id: Default::default(),
297            topics: Default::default(),
298            error_code: 0,
299            error_message: None,
300            unknown_tagged_fields: BTreeMap::new(),
301        }
302    }
303}
304
305impl Message for DescribeShareGroupOffsetsResponseGroup {
306    const VERSIONS: VersionRange = VersionRange { min: 0, max: 0 };
307    const DEPRECATED_VERSIONS: Option<VersionRange> = None;
308}
309
310/// Valid versions: 0
311#[non_exhaustive]
312#[derive(Debug, Clone, PartialEq)]
313pub struct DescribeShareGroupOffsetsResponsePartition {
314    /// The partition index.
315    ///
316    /// Supported API versions: 0
317    pub partition_index: i32,
318
319    /// The share-partition start offset.
320    ///
321    /// Supported API versions: 0
322    pub start_offset: i64,
323
324    /// The leader epoch of the partition.
325    ///
326    /// Supported API versions: 0
327    pub leader_epoch: i32,
328
329    /// The partition-level error code, or 0 if there was no error.
330    ///
331    /// Supported API versions: 0
332    pub error_code: i16,
333
334    /// The partition-level error message, or null if there was no error.
335    ///
336    /// Supported API versions: 0
337    pub error_message: Option<StrBytes>,
338
339    /// Other tagged fields
340    pub unknown_tagged_fields: BTreeMap<i32, Bytes>,
341}
342
343impl DescribeShareGroupOffsetsResponsePartition {
344    /// Sets `partition_index` to the passed value.
345    ///
346    /// The partition index.
347    ///
348    /// Supported API versions: 0
349    pub fn with_partition_index(mut self, value: i32) -> Self {
350        self.partition_index = value;
351        self
352    }
353    /// Sets `start_offset` to the passed value.
354    ///
355    /// The share-partition start offset.
356    ///
357    /// Supported API versions: 0
358    pub fn with_start_offset(mut self, value: i64) -> Self {
359        self.start_offset = value;
360        self
361    }
362    /// Sets `leader_epoch` to the passed value.
363    ///
364    /// The leader epoch of the partition.
365    ///
366    /// Supported API versions: 0
367    pub fn with_leader_epoch(mut self, value: i32) -> Self {
368        self.leader_epoch = value;
369        self
370    }
371    /// Sets `error_code` to the passed value.
372    ///
373    /// The partition-level error code, or 0 if there was no error.
374    ///
375    /// Supported API versions: 0
376    pub fn with_error_code(mut self, value: i16) -> Self {
377        self.error_code = value;
378        self
379    }
380    /// Sets `error_message` to the passed value.
381    ///
382    /// The partition-level error message, or null if there was no error.
383    ///
384    /// Supported API versions: 0
385    pub fn with_error_message(mut self, value: Option<StrBytes>) -> Self {
386        self.error_message = value;
387        self
388    }
389    /// Sets unknown_tagged_fields to the passed value.
390    pub fn with_unknown_tagged_fields(mut self, value: BTreeMap<i32, Bytes>) -> Self {
391        self.unknown_tagged_fields = value;
392        self
393    }
394    /// Inserts an entry into unknown_tagged_fields.
395    pub fn with_unknown_tagged_field(mut self, key: i32, value: Bytes) -> Self {
396        self.unknown_tagged_fields.insert(key, value);
397        self
398    }
399}
400
401#[cfg(feature = "broker")]
402impl Encodable for DescribeShareGroupOffsetsResponsePartition {
403    fn encode<B: ByteBufMut>(&self, buf: &mut B, version: i16) -> Result<()> {
404        if version != 0 {
405            bail!("specified version not supported by this message type");
406        }
407        types::Int32.encode(buf, &self.partition_index)?;
408        types::Int64.encode(buf, &self.start_offset)?;
409        types::Int32.encode(buf, &self.leader_epoch)?;
410        types::Int16.encode(buf, &self.error_code)?;
411        types::CompactString.encode(buf, &self.error_message)?;
412        let num_tagged_fields = self.unknown_tagged_fields.len();
413        if num_tagged_fields > std::u32::MAX as usize {
414            bail!(
415                "Too many tagged fields to encode ({} fields)",
416                num_tagged_fields
417            );
418        }
419        types::UnsignedVarInt.encode(buf, num_tagged_fields as u32)?;
420
421        write_unknown_tagged_fields(buf, 0.., &self.unknown_tagged_fields)?;
422        Ok(())
423    }
424    fn compute_size(&self, version: i16) -> Result<usize> {
425        let mut total_size = 0;
426        total_size += types::Int32.compute_size(&self.partition_index)?;
427        total_size += types::Int64.compute_size(&self.start_offset)?;
428        total_size += types::Int32.compute_size(&self.leader_epoch)?;
429        total_size += types::Int16.compute_size(&self.error_code)?;
430        total_size += types::CompactString.compute_size(&self.error_message)?;
431        let num_tagged_fields = self.unknown_tagged_fields.len();
432        if num_tagged_fields > std::u32::MAX as usize {
433            bail!(
434                "Too many tagged fields to encode ({} fields)",
435                num_tagged_fields
436            );
437        }
438        total_size += types::UnsignedVarInt.compute_size(num_tagged_fields as u32)?;
439
440        total_size += compute_unknown_tagged_fields_size(&self.unknown_tagged_fields)?;
441        Ok(total_size)
442    }
443}
444
445#[cfg(feature = "client")]
446impl Decodable for DescribeShareGroupOffsetsResponsePartition {
447    fn decode<B: ByteBuf>(buf: &mut B, version: i16) -> Result<Self> {
448        if version != 0 {
449            bail!("specified version not supported by this message type");
450        }
451        let partition_index = types::Int32.decode(buf)?;
452        let start_offset = types::Int64.decode(buf)?;
453        let leader_epoch = types::Int32.decode(buf)?;
454        let error_code = types::Int16.decode(buf)?;
455        let error_message = types::CompactString.decode(buf)?;
456        let mut unknown_tagged_fields = BTreeMap::new();
457        let num_tagged_fields = types::UnsignedVarInt.decode(buf)?;
458        for _ in 0..num_tagged_fields {
459            let tag: u32 = types::UnsignedVarInt.decode(buf)?;
460            let size: u32 = types::UnsignedVarInt.decode(buf)?;
461            let unknown_value = buf.try_get_bytes(size as usize)?;
462            unknown_tagged_fields.insert(tag as i32, unknown_value);
463        }
464        Ok(Self {
465            partition_index,
466            start_offset,
467            leader_epoch,
468            error_code,
469            error_message,
470            unknown_tagged_fields,
471        })
472    }
473}
474
475impl Default for DescribeShareGroupOffsetsResponsePartition {
476    fn default() -> Self {
477        Self {
478            partition_index: 0,
479            start_offset: 0,
480            leader_epoch: 0,
481            error_code: 0,
482            error_message: None,
483            unknown_tagged_fields: BTreeMap::new(),
484        }
485    }
486}
487
488impl Message for DescribeShareGroupOffsetsResponsePartition {
489    const VERSIONS: VersionRange = VersionRange { min: 0, max: 0 };
490    const DEPRECATED_VERSIONS: Option<VersionRange> = None;
491}
492
493/// Valid versions: 0
494#[non_exhaustive]
495#[derive(Debug, Clone, PartialEq)]
496pub struct DescribeShareGroupOffsetsResponseTopic {
497    /// The topic name.
498    ///
499    /// Supported API versions: 0
500    pub topic_name: super::TopicName,
501
502    /// The unique topic ID.
503    ///
504    /// Supported API versions: 0
505    pub topic_id: Uuid,
506
507    ///
508    ///
509    /// Supported API versions: 0
510    pub partitions: Vec<DescribeShareGroupOffsetsResponsePartition>,
511
512    /// Other tagged fields
513    pub unknown_tagged_fields: BTreeMap<i32, Bytes>,
514}
515
516impl DescribeShareGroupOffsetsResponseTopic {
517    /// Sets `topic_name` to the passed value.
518    ///
519    /// The topic name.
520    ///
521    /// Supported API versions: 0
522    pub fn with_topic_name(mut self, value: super::TopicName) -> Self {
523        self.topic_name = value;
524        self
525    }
526    /// Sets `topic_id` to the passed value.
527    ///
528    /// The unique topic ID.
529    ///
530    /// Supported API versions: 0
531    pub fn with_topic_id(mut self, value: Uuid) -> Self {
532        self.topic_id = value;
533        self
534    }
535    /// Sets `partitions` to the passed value.
536    ///
537    ///
538    ///
539    /// Supported API versions: 0
540    pub fn with_partitions(
541        mut self,
542        value: Vec<DescribeShareGroupOffsetsResponsePartition>,
543    ) -> Self {
544        self.partitions = value;
545        self
546    }
547    /// Sets unknown_tagged_fields to the passed value.
548    pub fn with_unknown_tagged_fields(mut self, value: BTreeMap<i32, Bytes>) -> Self {
549        self.unknown_tagged_fields = value;
550        self
551    }
552    /// Inserts an entry into unknown_tagged_fields.
553    pub fn with_unknown_tagged_field(mut self, key: i32, value: Bytes) -> Self {
554        self.unknown_tagged_fields.insert(key, value);
555        self
556    }
557}
558
559#[cfg(feature = "broker")]
560impl Encodable for DescribeShareGroupOffsetsResponseTopic {
561    fn encode<B: ByteBufMut>(&self, buf: &mut B, version: i16) -> Result<()> {
562        if version != 0 {
563            bail!("specified version not supported by this message type");
564        }
565        types::CompactString.encode(buf, &self.topic_name)?;
566        types::Uuid.encode(buf, &self.topic_id)?;
567        types::CompactArray(types::Struct { version }).encode(buf, &self.partitions)?;
568        let num_tagged_fields = self.unknown_tagged_fields.len();
569        if num_tagged_fields > std::u32::MAX as usize {
570            bail!(
571                "Too many tagged fields to encode ({} fields)",
572                num_tagged_fields
573            );
574        }
575        types::UnsignedVarInt.encode(buf, num_tagged_fields as u32)?;
576
577        write_unknown_tagged_fields(buf, 0.., &self.unknown_tagged_fields)?;
578        Ok(())
579    }
580    fn compute_size(&self, version: i16) -> Result<usize> {
581        let mut total_size = 0;
582        total_size += types::CompactString.compute_size(&self.topic_name)?;
583        total_size += types::Uuid.compute_size(&self.topic_id)?;
584        total_size +=
585            types::CompactArray(types::Struct { version }).compute_size(&self.partitions)?;
586        let num_tagged_fields = self.unknown_tagged_fields.len();
587        if num_tagged_fields > std::u32::MAX as usize {
588            bail!(
589                "Too many tagged fields to encode ({} fields)",
590                num_tagged_fields
591            );
592        }
593        total_size += types::UnsignedVarInt.compute_size(num_tagged_fields as u32)?;
594
595        total_size += compute_unknown_tagged_fields_size(&self.unknown_tagged_fields)?;
596        Ok(total_size)
597    }
598}
599
600#[cfg(feature = "client")]
601impl Decodable for DescribeShareGroupOffsetsResponseTopic {
602    fn decode<B: ByteBuf>(buf: &mut B, version: i16) -> Result<Self> {
603        if version != 0 {
604            bail!("specified version not supported by this message type");
605        }
606        let topic_name = types::CompactString.decode(buf)?;
607        let topic_id = types::Uuid.decode(buf)?;
608        let partitions = types::CompactArray(types::Struct { version }).decode(buf)?;
609        let mut unknown_tagged_fields = BTreeMap::new();
610        let num_tagged_fields = types::UnsignedVarInt.decode(buf)?;
611        for _ in 0..num_tagged_fields {
612            let tag: u32 = types::UnsignedVarInt.decode(buf)?;
613            let size: u32 = types::UnsignedVarInt.decode(buf)?;
614            let unknown_value = buf.try_get_bytes(size as usize)?;
615            unknown_tagged_fields.insert(tag as i32, unknown_value);
616        }
617        Ok(Self {
618            topic_name,
619            topic_id,
620            partitions,
621            unknown_tagged_fields,
622        })
623    }
624}
625
626impl Default for DescribeShareGroupOffsetsResponseTopic {
627    fn default() -> Self {
628        Self {
629            topic_name: Default::default(),
630            topic_id: Uuid::nil(),
631            partitions: Default::default(),
632            unknown_tagged_fields: BTreeMap::new(),
633        }
634    }
635}
636
637impl Message for DescribeShareGroupOffsetsResponseTopic {
638    const VERSIONS: VersionRange = VersionRange { min: 0, max: 0 };
639    const DEPRECATED_VERSIONS: Option<VersionRange> = None;
640}
641
642impl HeaderVersion for DescribeShareGroupOffsetsResponse {
643    fn header_version(version: i16) -> i16 {
644        1
645    }
646}