kafka_protocol/messages/
delete_share_group_state_request.rs

1//! DeleteShareGroupStateRequest
2//!
3//! See the schema for this message [here](https://github.com/apache/kafka/blob/trunk/clients/src/main/resources/common/message/DeleteShareGroupStateRequest.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 DeleteShareGroupStateRequest {
24    /// The group identifier.
25    ///
26    /// Supported API versions: 0
27    pub group_id: StrBytes,
28
29    /// The data for the topics.
30    ///
31    /// Supported API versions: 0
32    pub topics: Vec<DeleteStateData>,
33
34    /// Other tagged fields
35    pub unknown_tagged_fields: BTreeMap<i32, Bytes>,
36}
37
38impl DeleteShareGroupStateRequest {
39    /// Sets `group_id` to the passed value.
40    ///
41    /// The group identifier.
42    ///
43    /// Supported API versions: 0
44    pub fn with_group_id(mut self, value: StrBytes) -> Self {
45        self.group_id = value;
46        self
47    }
48    /// Sets `topics` to the passed value.
49    ///
50    /// The data for the topics.
51    ///
52    /// Supported API versions: 0
53    pub fn with_topics(mut self, value: Vec<DeleteStateData>) -> Self {
54        self.topics = 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 = "client")]
70impl Encodable for DeleteShareGroupStateRequest {
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::CompactString.encode(buf, &self.group_id)?;
76        types::CompactArray(types::Struct { version }).encode(buf, &self.topics)?;
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::CompactString.compute_size(&self.group_id)?;
92        total_size += types::CompactArray(types::Struct { version }).compute_size(&self.topics)?;
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 = "broker")]
108impl Decodable for DeleteShareGroupStateRequest {
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 group_id = types::CompactString.decode(buf)?;
114        let topics = 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            group_id,
125            topics,
126            unknown_tagged_fields,
127        })
128    }
129}
130
131impl Default for DeleteShareGroupStateRequest {
132    fn default() -> Self {
133        Self {
134            group_id: Default::default(),
135            topics: Default::default(),
136            unknown_tagged_fields: BTreeMap::new(),
137        }
138    }
139}
140
141impl Message for DeleteShareGroupStateRequest {
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 DeleteStateData {
150    /// The topic identifier.
151    ///
152    /// Supported API versions: 0
153    pub topic_id: Uuid,
154
155    /// The data for the partitions.
156    ///
157    /// Supported API versions: 0
158    pub partitions: Vec<PartitionData>,
159
160    /// Other tagged fields
161    pub unknown_tagged_fields: BTreeMap<i32, Bytes>,
162}
163
164impl DeleteStateData {
165    /// Sets `topic_id` to the passed value.
166    ///
167    /// The topic identifier.
168    ///
169    /// Supported API versions: 0
170    pub fn with_topic_id(mut self, value: Uuid) -> Self {
171        self.topic_id = value;
172        self
173    }
174    /// Sets `partitions` to the passed value.
175    ///
176    /// The data for the partitions.
177    ///
178    /// Supported API versions: 0
179    pub fn with_partitions(mut self, value: Vec<PartitionData>) -> Self {
180        self.partitions = value;
181        self
182    }
183    /// Sets unknown_tagged_fields to the passed value.
184    pub fn with_unknown_tagged_fields(mut self, value: BTreeMap<i32, Bytes>) -> Self {
185        self.unknown_tagged_fields = value;
186        self
187    }
188    /// Inserts an entry into unknown_tagged_fields.
189    pub fn with_unknown_tagged_field(mut self, key: i32, value: Bytes) -> Self {
190        self.unknown_tagged_fields.insert(key, value);
191        self
192    }
193}
194
195#[cfg(feature = "client")]
196impl Encodable for DeleteStateData {
197    fn encode<B: ByteBufMut>(&self, buf: &mut B, version: i16) -> Result<()> {
198        if version != 0 {
199            bail!("specified version not supported by this message type");
200        }
201        types::Uuid.encode(buf, &self.topic_id)?;
202        types::CompactArray(types::Struct { version }).encode(buf, &self.partitions)?;
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        types::UnsignedVarInt.encode(buf, num_tagged_fields as u32)?;
211
212        write_unknown_tagged_fields(buf, 0.., &self.unknown_tagged_fields)?;
213        Ok(())
214    }
215    fn compute_size(&self, version: i16) -> Result<usize> {
216        let mut total_size = 0;
217        total_size += types::Uuid.compute_size(&self.topic_id)?;
218        total_size +=
219            types::CompactArray(types::Struct { version }).compute_size(&self.partitions)?;
220        let num_tagged_fields = self.unknown_tagged_fields.len();
221        if num_tagged_fields > std::u32::MAX as usize {
222            bail!(
223                "Too many tagged fields to encode ({} fields)",
224                num_tagged_fields
225            );
226        }
227        total_size += types::UnsignedVarInt.compute_size(num_tagged_fields as u32)?;
228
229        total_size += compute_unknown_tagged_fields_size(&self.unknown_tagged_fields)?;
230        Ok(total_size)
231    }
232}
233
234#[cfg(feature = "broker")]
235impl Decodable for DeleteStateData {
236    fn decode<B: ByteBuf>(buf: &mut B, version: i16) -> Result<Self> {
237        if version != 0 {
238            bail!("specified version not supported by this message type");
239        }
240        let topic_id = types::Uuid.decode(buf)?;
241        let partitions = types::CompactArray(types::Struct { version }).decode(buf)?;
242        let mut unknown_tagged_fields = BTreeMap::new();
243        let num_tagged_fields = types::UnsignedVarInt.decode(buf)?;
244        for _ in 0..num_tagged_fields {
245            let tag: u32 = types::UnsignedVarInt.decode(buf)?;
246            let size: u32 = types::UnsignedVarInt.decode(buf)?;
247            let unknown_value = buf.try_get_bytes(size as usize)?;
248            unknown_tagged_fields.insert(tag as i32, unknown_value);
249        }
250        Ok(Self {
251            topic_id,
252            partitions,
253            unknown_tagged_fields,
254        })
255    }
256}
257
258impl Default for DeleteStateData {
259    fn default() -> Self {
260        Self {
261            topic_id: Uuid::nil(),
262            partitions: Default::default(),
263            unknown_tagged_fields: BTreeMap::new(),
264        }
265    }
266}
267
268impl Message for DeleteStateData {
269    const VERSIONS: VersionRange = VersionRange { min: 0, max: 0 };
270    const DEPRECATED_VERSIONS: Option<VersionRange> = None;
271}
272
273/// Valid versions: 0
274#[non_exhaustive]
275#[derive(Debug, Clone, PartialEq)]
276pub struct PartitionData {
277    /// The partition index.
278    ///
279    /// Supported API versions: 0
280    pub partition: i32,
281
282    /// Other tagged fields
283    pub unknown_tagged_fields: BTreeMap<i32, Bytes>,
284}
285
286impl PartitionData {
287    /// Sets `partition` to the passed value.
288    ///
289    /// The partition index.
290    ///
291    /// Supported API versions: 0
292    pub fn with_partition(mut self, value: i32) -> Self {
293        self.partition = value;
294        self
295    }
296    /// Sets unknown_tagged_fields to the passed value.
297    pub fn with_unknown_tagged_fields(mut self, value: BTreeMap<i32, Bytes>) -> Self {
298        self.unknown_tagged_fields = value;
299        self
300    }
301    /// Inserts an entry into unknown_tagged_fields.
302    pub fn with_unknown_tagged_field(mut self, key: i32, value: Bytes) -> Self {
303        self.unknown_tagged_fields.insert(key, value);
304        self
305    }
306}
307
308#[cfg(feature = "client")]
309impl Encodable for PartitionData {
310    fn encode<B: ByteBufMut>(&self, buf: &mut B, version: i16) -> Result<()> {
311        if version != 0 {
312            bail!("specified version not supported by this message type");
313        }
314        types::Int32.encode(buf, &self.partition)?;
315        let num_tagged_fields = self.unknown_tagged_fields.len();
316        if num_tagged_fields > std::u32::MAX as usize {
317            bail!(
318                "Too many tagged fields to encode ({} fields)",
319                num_tagged_fields
320            );
321        }
322        types::UnsignedVarInt.encode(buf, num_tagged_fields as u32)?;
323
324        write_unknown_tagged_fields(buf, 0.., &self.unknown_tagged_fields)?;
325        Ok(())
326    }
327    fn compute_size(&self, version: i16) -> Result<usize> {
328        let mut total_size = 0;
329        total_size += types::Int32.compute_size(&self.partition)?;
330        let num_tagged_fields = self.unknown_tagged_fields.len();
331        if num_tagged_fields > std::u32::MAX as usize {
332            bail!(
333                "Too many tagged fields to encode ({} fields)",
334                num_tagged_fields
335            );
336        }
337        total_size += types::UnsignedVarInt.compute_size(num_tagged_fields as u32)?;
338
339        total_size += compute_unknown_tagged_fields_size(&self.unknown_tagged_fields)?;
340        Ok(total_size)
341    }
342}
343
344#[cfg(feature = "broker")]
345impl Decodable for PartitionData {
346    fn decode<B: ByteBuf>(buf: &mut B, version: i16) -> Result<Self> {
347        if version != 0 {
348            bail!("specified version not supported by this message type");
349        }
350        let partition = 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            partition,
361            unknown_tagged_fields,
362        })
363    }
364}
365
366impl Default for PartitionData {
367    fn default() -> Self {
368        Self {
369            partition: 0,
370            unknown_tagged_fields: BTreeMap::new(),
371        }
372    }
373}
374
375impl Message for PartitionData {
376    const VERSIONS: VersionRange = VersionRange { min: 0, max: 0 };
377    const DEPRECATED_VERSIONS: Option<VersionRange> = None;
378}
379
380impl HeaderVersion for DeleteShareGroupStateRequest {
381    fn header_version(version: i16) -> i16 {
382        2
383    }
384}