kafka_protocol/messages/
delete_share_group_offsets_response.rs

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