kafka_protocol/messages/
offset_delete_response.rs

1//! OffsetDeleteResponse
2//!
3//! See the schema for this message [here](https://github.com/apache/kafka/blob/trunk/clients/src/main/resources/common/message/OffsetDeleteResponse.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 OffsetDeleteResponse {
24    /// The top-level error code, or 0 if there was no error.
25    ///
26    /// Supported API versions: 0
27    pub error_code: i16,
28
29    /// 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.
30    ///
31    /// Supported API versions: 0
32    pub throttle_time_ms: i32,
33
34    /// The responses for each topic.
35    ///
36    /// Supported API versions: 0
37    pub topics: Vec<OffsetDeleteResponseTopic>,
38}
39
40impl OffsetDeleteResponse {
41    /// Sets `error_code` to the passed value.
42    ///
43    /// The top-level error code, or 0 if there was no error.
44    ///
45    /// Supported API versions: 0
46    pub fn with_error_code(mut self, value: i16) -> Self {
47        self.error_code = value;
48        self
49    }
50    /// Sets `throttle_time_ms` to the passed value.
51    ///
52    /// 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.
53    ///
54    /// Supported API versions: 0
55    pub fn with_throttle_time_ms(mut self, value: i32) -> Self {
56        self.throttle_time_ms = value;
57        self
58    }
59    /// Sets `topics` to the passed value.
60    ///
61    /// The responses for each topic.
62    ///
63    /// Supported API versions: 0
64    pub fn with_topics(mut self, value: Vec<OffsetDeleteResponseTopic>) -> Self {
65        self.topics = value;
66        self
67    }
68}
69
70#[cfg(feature = "broker")]
71impl Encodable for OffsetDeleteResponse {
72    fn encode<B: ByteBufMut>(&self, buf: &mut B, version: i16) -> Result<()> {
73        if version != 0 {
74            bail!("specified version not supported by this message type");
75        }
76        types::Int16.encode(buf, &self.error_code)?;
77        types::Int32.encode(buf, &self.throttle_time_ms)?;
78        types::Array(types::Struct { version }).encode(buf, &self.topics)?;
79
80        Ok(())
81    }
82    fn compute_size(&self, version: i16) -> Result<usize> {
83        let mut total_size = 0;
84        total_size += types::Int16.compute_size(&self.error_code)?;
85        total_size += types::Int32.compute_size(&self.throttle_time_ms)?;
86        total_size += types::Array(types::Struct { version }).compute_size(&self.topics)?;
87
88        Ok(total_size)
89    }
90}
91
92#[cfg(feature = "client")]
93impl Decodable for OffsetDeleteResponse {
94    fn decode<B: ByteBuf>(buf: &mut B, version: i16) -> Result<Self> {
95        if version != 0 {
96            bail!("specified version not supported by this message type");
97        }
98        let error_code = types::Int16.decode(buf)?;
99        let throttle_time_ms = types::Int32.decode(buf)?;
100        let topics = types::Array(types::Struct { version }).decode(buf)?;
101        Ok(Self {
102            error_code,
103            throttle_time_ms,
104            topics,
105        })
106    }
107}
108
109impl Default for OffsetDeleteResponse {
110    fn default() -> Self {
111        Self {
112            error_code: 0,
113            throttle_time_ms: 0,
114            topics: Default::default(),
115        }
116    }
117}
118
119impl Message for OffsetDeleteResponse {
120    const VERSIONS: VersionRange = VersionRange { min: 0, max: 0 };
121    const DEPRECATED_VERSIONS: Option<VersionRange> = None;
122}
123
124/// Valid versions: 0
125#[non_exhaustive]
126#[derive(Debug, Clone, PartialEq)]
127pub struct OffsetDeleteResponsePartition {
128    /// The partition index.
129    ///
130    /// Supported API versions: 0
131    pub partition_index: i32,
132
133    /// The error code, or 0 if there was no error.
134    ///
135    /// Supported API versions: 0
136    pub error_code: i16,
137}
138
139impl OffsetDeleteResponsePartition {
140    /// Sets `partition_index` to the passed value.
141    ///
142    /// The partition index.
143    ///
144    /// Supported API versions: 0
145    pub fn with_partition_index(mut self, value: i32) -> Self {
146        self.partition_index = value;
147        self
148    }
149    /// Sets `error_code` to the passed value.
150    ///
151    /// The error code, or 0 if there was no error.
152    ///
153    /// Supported API versions: 0
154    pub fn with_error_code(mut self, value: i16) -> Self {
155        self.error_code = value;
156        self
157    }
158}
159
160#[cfg(feature = "broker")]
161impl Encodable for OffsetDeleteResponsePartition {
162    fn encode<B: ByteBufMut>(&self, buf: &mut B, version: i16) -> Result<()> {
163        if version != 0 {
164            bail!("specified version not supported by this message type");
165        }
166        types::Int32.encode(buf, &self.partition_index)?;
167        types::Int16.encode(buf, &self.error_code)?;
168
169        Ok(())
170    }
171    fn compute_size(&self, version: i16) -> Result<usize> {
172        let mut total_size = 0;
173        total_size += types::Int32.compute_size(&self.partition_index)?;
174        total_size += types::Int16.compute_size(&self.error_code)?;
175
176        Ok(total_size)
177    }
178}
179
180#[cfg(feature = "client")]
181impl Decodable for OffsetDeleteResponsePartition {
182    fn decode<B: ByteBuf>(buf: &mut B, version: i16) -> Result<Self> {
183        if version != 0 {
184            bail!("specified version not supported by this message type");
185        }
186        let partition_index = types::Int32.decode(buf)?;
187        let error_code = types::Int16.decode(buf)?;
188        Ok(Self {
189            partition_index,
190            error_code,
191        })
192    }
193}
194
195impl Default for OffsetDeleteResponsePartition {
196    fn default() -> Self {
197        Self {
198            partition_index: 0,
199            error_code: 0,
200        }
201    }
202}
203
204impl Message for OffsetDeleteResponsePartition {
205    const VERSIONS: VersionRange = VersionRange { min: 0, max: 0 };
206    const DEPRECATED_VERSIONS: Option<VersionRange> = None;
207}
208
209/// Valid versions: 0
210#[non_exhaustive]
211#[derive(Debug, Clone, PartialEq)]
212pub struct OffsetDeleteResponseTopic {
213    /// The topic name.
214    ///
215    /// Supported API versions: 0
216    pub name: super::TopicName,
217
218    /// The responses for each partition in the topic.
219    ///
220    /// Supported API versions: 0
221    pub partitions: Vec<OffsetDeleteResponsePartition>,
222}
223
224impl OffsetDeleteResponseTopic {
225    /// Sets `name` to the passed value.
226    ///
227    /// The topic name.
228    ///
229    /// Supported API versions: 0
230    pub fn with_name(mut self, value: super::TopicName) -> Self {
231        self.name = value;
232        self
233    }
234    /// Sets `partitions` to the passed value.
235    ///
236    /// The responses for each partition in the topic.
237    ///
238    /// Supported API versions: 0
239    pub fn with_partitions(mut self, value: Vec<OffsetDeleteResponsePartition>) -> Self {
240        self.partitions = value;
241        self
242    }
243}
244
245#[cfg(feature = "broker")]
246impl Encodable for OffsetDeleteResponseTopic {
247    fn encode<B: ByteBufMut>(&self, buf: &mut B, version: i16) -> Result<()> {
248        if version != 0 {
249            bail!("specified version not supported by this message type");
250        }
251        types::String.encode(buf, &self.name)?;
252        types::Array(types::Struct { version }).encode(buf, &self.partitions)?;
253
254        Ok(())
255    }
256    fn compute_size(&self, version: i16) -> Result<usize> {
257        let mut total_size = 0;
258        total_size += types::String.compute_size(&self.name)?;
259        total_size += types::Array(types::Struct { version }).compute_size(&self.partitions)?;
260
261        Ok(total_size)
262    }
263}
264
265#[cfg(feature = "client")]
266impl Decodable for OffsetDeleteResponseTopic {
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 name = types::String.decode(buf)?;
272        let partitions = types::Array(types::Struct { version }).decode(buf)?;
273        Ok(Self { name, partitions })
274    }
275}
276
277impl Default for OffsetDeleteResponseTopic {
278    fn default() -> Self {
279        Self {
280            name: Default::default(),
281            partitions: Default::default(),
282        }
283    }
284}
285
286impl Message for OffsetDeleteResponseTopic {
287    const VERSIONS: VersionRange = VersionRange { min: 0, max: 0 };
288    const DEPRECATED_VERSIONS: Option<VersionRange> = None;
289}
290
291impl HeaderVersion for OffsetDeleteResponse {
292    fn header_version(version: i16) -> i16 {
293        0
294    }
295}