kafka_protocol/messages/
describe_share_group_offsets_request.rs

1//! DescribeShareGroupOffsetsRequest
2//!
3//! See the schema for this message [here](https://github.com/apache/kafka/blob/trunk/clients/src/main/resources/common/message/DescribeShareGroupOffsetsRequest.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 DescribeShareGroupOffsetsRequest {
24    /// The groups to describe offsets for.
25    ///
26    /// Supported API versions: 0
27    pub groups: Vec<DescribeShareGroupOffsetsRequestGroup>,
28
29    /// Other tagged fields
30    pub unknown_tagged_fields: BTreeMap<i32, Bytes>,
31}
32
33impl DescribeShareGroupOffsetsRequest {
34    /// Sets `groups` to the passed value.
35    ///
36    /// The groups to describe offsets for.
37    ///
38    /// Supported API versions: 0
39    pub fn with_groups(mut self, value: Vec<DescribeShareGroupOffsetsRequestGroup>) -> Self {
40        self.groups = value;
41        self
42    }
43    /// Sets unknown_tagged_fields to the passed value.
44    pub fn with_unknown_tagged_fields(mut self, value: BTreeMap<i32, Bytes>) -> Self {
45        self.unknown_tagged_fields = value;
46        self
47    }
48    /// Inserts an entry into unknown_tagged_fields.
49    pub fn with_unknown_tagged_field(mut self, key: i32, value: Bytes) -> Self {
50        self.unknown_tagged_fields.insert(key, value);
51        self
52    }
53}
54
55#[cfg(feature = "client")]
56impl Encodable for DescribeShareGroupOffsetsRequest {
57    fn encode<B: ByteBufMut>(&self, buf: &mut B, version: i16) -> Result<()> {
58        if version != 0 {
59            bail!("specified version not supported by this message type");
60        }
61        types::CompactArray(types::Struct { version }).encode(buf, &self.groups)?;
62        let num_tagged_fields = self.unknown_tagged_fields.len();
63        if num_tagged_fields > std::u32::MAX as usize {
64            bail!(
65                "Too many tagged fields to encode ({} fields)",
66                num_tagged_fields
67            );
68        }
69        types::UnsignedVarInt.encode(buf, num_tagged_fields as u32)?;
70
71        write_unknown_tagged_fields(buf, 0.., &self.unknown_tagged_fields)?;
72        Ok(())
73    }
74    fn compute_size(&self, version: i16) -> Result<usize> {
75        let mut total_size = 0;
76        total_size += types::CompactArray(types::Struct { version }).compute_size(&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        total_size += types::UnsignedVarInt.compute_size(num_tagged_fields as u32)?;
85
86        total_size += compute_unknown_tagged_fields_size(&self.unknown_tagged_fields)?;
87        Ok(total_size)
88    }
89}
90
91#[cfg(feature = "broker")]
92impl Decodable for DescribeShareGroupOffsetsRequest {
93    fn decode<B: ByteBuf>(buf: &mut B, version: i16) -> Result<Self> {
94        if version != 0 {
95            bail!("specified version not supported by this message type");
96        }
97        let groups = types::CompactArray(types::Struct { version }).decode(buf)?;
98        let mut unknown_tagged_fields = BTreeMap::new();
99        let num_tagged_fields = types::UnsignedVarInt.decode(buf)?;
100        for _ in 0..num_tagged_fields {
101            let tag: u32 = types::UnsignedVarInt.decode(buf)?;
102            let size: u32 = types::UnsignedVarInt.decode(buf)?;
103            let unknown_value = buf.try_get_bytes(size as usize)?;
104            unknown_tagged_fields.insert(tag as i32, unknown_value);
105        }
106        Ok(Self {
107            groups,
108            unknown_tagged_fields,
109        })
110    }
111}
112
113impl Default for DescribeShareGroupOffsetsRequest {
114    fn default() -> Self {
115        Self {
116            groups: Default::default(),
117            unknown_tagged_fields: BTreeMap::new(),
118        }
119    }
120}
121
122impl Message for DescribeShareGroupOffsetsRequest {
123    const VERSIONS: VersionRange = VersionRange { min: 0, max: 0 };
124    const DEPRECATED_VERSIONS: Option<VersionRange> = None;
125}
126
127/// Valid versions: 0
128#[non_exhaustive]
129#[derive(Debug, Clone, PartialEq)]
130pub struct DescribeShareGroupOffsetsRequestGroup {
131    /// The group identifier.
132    ///
133    /// Supported API versions: 0
134    pub group_id: super::GroupId,
135
136    /// The topics to describe offsets for, or null for all topic-partitions.
137    ///
138    /// Supported API versions: 0
139    pub topics: Option<Vec<DescribeShareGroupOffsetsRequestTopic>>,
140
141    /// Other tagged fields
142    pub unknown_tagged_fields: BTreeMap<i32, Bytes>,
143}
144
145impl DescribeShareGroupOffsetsRequestGroup {
146    /// Sets `group_id` to the passed value.
147    ///
148    /// The group identifier.
149    ///
150    /// Supported API versions: 0
151    pub fn with_group_id(mut self, value: super::GroupId) -> Self {
152        self.group_id = value;
153        self
154    }
155    /// Sets `topics` to the passed value.
156    ///
157    /// The topics to describe offsets for, or null for all topic-partitions.
158    ///
159    /// Supported API versions: 0
160    pub fn with_topics(
161        mut self,
162        value: Option<Vec<DescribeShareGroupOffsetsRequestTopic>>,
163    ) -> Self {
164        self.topics = value;
165        self
166    }
167    /// Sets unknown_tagged_fields to the passed value.
168    pub fn with_unknown_tagged_fields(mut self, value: BTreeMap<i32, Bytes>) -> Self {
169        self.unknown_tagged_fields = value;
170        self
171    }
172    /// Inserts an entry into unknown_tagged_fields.
173    pub fn with_unknown_tagged_field(mut self, key: i32, value: Bytes) -> Self {
174        self.unknown_tagged_fields.insert(key, value);
175        self
176    }
177}
178
179#[cfg(feature = "client")]
180impl Encodable for DescribeShareGroupOffsetsRequestGroup {
181    fn encode<B: ByteBufMut>(&self, buf: &mut B, version: i16) -> Result<()> {
182        if version != 0 {
183            bail!("specified version not supported by this message type");
184        }
185        types::CompactString.encode(buf, &self.group_id)?;
186        types::CompactArray(types::Struct { version }).encode(buf, &self.topics)?;
187        let num_tagged_fields = self.unknown_tagged_fields.len();
188        if num_tagged_fields > std::u32::MAX as usize {
189            bail!(
190                "Too many tagged fields to encode ({} fields)",
191                num_tagged_fields
192            );
193        }
194        types::UnsignedVarInt.encode(buf, num_tagged_fields as u32)?;
195
196        write_unknown_tagged_fields(buf, 0.., &self.unknown_tagged_fields)?;
197        Ok(())
198    }
199    fn compute_size(&self, version: i16) -> Result<usize> {
200        let mut total_size = 0;
201        total_size += types::CompactString.compute_size(&self.group_id)?;
202        total_size += types::CompactArray(types::Struct { version }).compute_size(&self.topics)?;
203        let num_tagged_fields = self.unknown_tagged_fields.len();
204        if num_tagged_fields > std::u32::MAX as usize {
205            bail!(
206                "Too many tagged fields to encode ({} fields)",
207                num_tagged_fields
208            );
209        }
210        total_size += types::UnsignedVarInt.compute_size(num_tagged_fields as u32)?;
211
212        total_size += compute_unknown_tagged_fields_size(&self.unknown_tagged_fields)?;
213        Ok(total_size)
214    }
215}
216
217#[cfg(feature = "broker")]
218impl Decodable for DescribeShareGroupOffsetsRequestGroup {
219    fn decode<B: ByteBuf>(buf: &mut B, version: i16) -> Result<Self> {
220        if version != 0 {
221            bail!("specified version not supported by this message type");
222        }
223        let group_id = types::CompactString.decode(buf)?;
224        let topics = types::CompactArray(types::Struct { version }).decode(buf)?;
225        let mut unknown_tagged_fields = BTreeMap::new();
226        let num_tagged_fields = types::UnsignedVarInt.decode(buf)?;
227        for _ in 0..num_tagged_fields {
228            let tag: u32 = types::UnsignedVarInt.decode(buf)?;
229            let size: u32 = types::UnsignedVarInt.decode(buf)?;
230            let unknown_value = buf.try_get_bytes(size as usize)?;
231            unknown_tagged_fields.insert(tag as i32, unknown_value);
232        }
233        Ok(Self {
234            group_id,
235            topics,
236            unknown_tagged_fields,
237        })
238    }
239}
240
241impl Default for DescribeShareGroupOffsetsRequestGroup {
242    fn default() -> Self {
243        Self {
244            group_id: Default::default(),
245            topics: Some(Default::default()),
246            unknown_tagged_fields: BTreeMap::new(),
247        }
248    }
249}
250
251impl Message for DescribeShareGroupOffsetsRequestGroup {
252    const VERSIONS: VersionRange = VersionRange { min: 0, max: 0 };
253    const DEPRECATED_VERSIONS: Option<VersionRange> = None;
254}
255
256/// Valid versions: 0
257#[non_exhaustive]
258#[derive(Debug, Clone, PartialEq)]
259pub struct DescribeShareGroupOffsetsRequestTopic {
260    /// The topic name.
261    ///
262    /// Supported API versions: 0
263    pub topic_name: super::TopicName,
264
265    /// The partitions.
266    ///
267    /// Supported API versions: 0
268    pub partitions: Vec<i32>,
269
270    /// Other tagged fields
271    pub unknown_tagged_fields: BTreeMap<i32, Bytes>,
272}
273
274impl DescribeShareGroupOffsetsRequestTopic {
275    /// Sets `topic_name` to the passed value.
276    ///
277    /// The topic name.
278    ///
279    /// Supported API versions: 0
280    pub fn with_topic_name(mut self, value: super::TopicName) -> Self {
281        self.topic_name = value;
282        self
283    }
284    /// Sets `partitions` to the passed value.
285    ///
286    /// The partitions.
287    ///
288    /// Supported API versions: 0
289    pub fn with_partitions(mut self, value: Vec<i32>) -> Self {
290        self.partitions = value;
291        self
292    }
293    /// Sets unknown_tagged_fields to the passed value.
294    pub fn with_unknown_tagged_fields(mut self, value: BTreeMap<i32, Bytes>) -> Self {
295        self.unknown_tagged_fields = value;
296        self
297    }
298    /// Inserts an entry into unknown_tagged_fields.
299    pub fn with_unknown_tagged_field(mut self, key: i32, value: Bytes) -> Self {
300        self.unknown_tagged_fields.insert(key, value);
301        self
302    }
303}
304
305#[cfg(feature = "client")]
306impl Encodable for DescribeShareGroupOffsetsRequestTopic {
307    fn encode<B: ByteBufMut>(&self, buf: &mut B, version: i16) -> Result<()> {
308        if version != 0 {
309            bail!("specified version not supported by this message type");
310        }
311        types::CompactString.encode(buf, &self.topic_name)?;
312        types::CompactArray(types::Int32).encode(buf, &self.partitions)?;
313        let num_tagged_fields = self.unknown_tagged_fields.len();
314        if num_tagged_fields > std::u32::MAX as usize {
315            bail!(
316                "Too many tagged fields to encode ({} fields)",
317                num_tagged_fields
318            );
319        }
320        types::UnsignedVarInt.encode(buf, num_tagged_fields as u32)?;
321
322        write_unknown_tagged_fields(buf, 0.., &self.unknown_tagged_fields)?;
323        Ok(())
324    }
325    fn compute_size(&self, version: i16) -> Result<usize> {
326        let mut total_size = 0;
327        total_size += types::CompactString.compute_size(&self.topic_name)?;
328        total_size += types::CompactArray(types::Int32).compute_size(&self.partitions)?;
329        let num_tagged_fields = self.unknown_tagged_fields.len();
330        if num_tagged_fields > std::u32::MAX as usize {
331            bail!(
332                "Too many tagged fields to encode ({} fields)",
333                num_tagged_fields
334            );
335        }
336        total_size += types::UnsignedVarInt.compute_size(num_tagged_fields as u32)?;
337
338        total_size += compute_unknown_tagged_fields_size(&self.unknown_tagged_fields)?;
339        Ok(total_size)
340    }
341}
342
343#[cfg(feature = "broker")]
344impl Decodable for DescribeShareGroupOffsetsRequestTopic {
345    fn decode<B: ByteBuf>(buf: &mut B, version: i16) -> Result<Self> {
346        if version != 0 {
347            bail!("specified version not supported by this message type");
348        }
349        let topic_name = types::CompactString.decode(buf)?;
350        let partitions = types::CompactArray(types::Int32).decode(buf)?;
351        let mut unknown_tagged_fields = BTreeMap::new();
352        let num_tagged_fields = types::UnsignedVarInt.decode(buf)?;
353        for _ in 0..num_tagged_fields {
354            let tag: u32 = types::UnsignedVarInt.decode(buf)?;
355            let size: u32 = types::UnsignedVarInt.decode(buf)?;
356            let unknown_value = buf.try_get_bytes(size as usize)?;
357            unknown_tagged_fields.insert(tag as i32, unknown_value);
358        }
359        Ok(Self {
360            topic_name,
361            partitions,
362            unknown_tagged_fields,
363        })
364    }
365}
366
367impl Default for DescribeShareGroupOffsetsRequestTopic {
368    fn default() -> Self {
369        Self {
370            topic_name: Default::default(),
371            partitions: Default::default(),
372            unknown_tagged_fields: BTreeMap::new(),
373        }
374    }
375}
376
377impl Message for DescribeShareGroupOffsetsRequestTopic {
378    const VERSIONS: VersionRange = VersionRange { min: 0, max: 0 };
379    const DEPRECATED_VERSIONS: Option<VersionRange> = None;
380}
381
382impl HeaderVersion for DescribeShareGroupOffsetsRequest {
383    fn header_version(version: i16) -> i16 {
384        2
385    }
386}