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        types::Int16.encode(buf, &self.error_code)?;
74        types::Int32.encode(buf, &self.throttle_time_ms)?;
75        types::Array(types::Struct { version }).encode(buf, &self.topics)?;
76
77        Ok(())
78    }
79    fn compute_size(&self, version: i16) -> Result<usize> {
80        let mut total_size = 0;
81        total_size += types::Int16.compute_size(&self.error_code)?;
82        total_size += types::Int32.compute_size(&self.throttle_time_ms)?;
83        total_size += types::Array(types::Struct { version }).compute_size(&self.topics)?;
84
85        Ok(total_size)
86    }
87}
88
89#[cfg(feature = "client")]
90impl Decodable for OffsetDeleteResponse {
91    fn decode<B: ByteBuf>(buf: &mut B, version: i16) -> Result<Self> {
92        let error_code = types::Int16.decode(buf)?;
93        let throttle_time_ms = types::Int32.decode(buf)?;
94        let topics = types::Array(types::Struct { version }).decode(buf)?;
95        Ok(Self {
96            error_code,
97            throttle_time_ms,
98            topics,
99        })
100    }
101}
102
103impl Default for OffsetDeleteResponse {
104    fn default() -> Self {
105        Self {
106            error_code: 0,
107            throttle_time_ms: 0,
108            topics: Default::default(),
109        }
110    }
111}
112
113impl Message for OffsetDeleteResponse {
114    const VERSIONS: VersionRange = VersionRange { min: 0, max: 0 };
115    const DEPRECATED_VERSIONS: Option<VersionRange> = None;
116}
117
118/// Valid versions: 0
119#[non_exhaustive]
120#[derive(Debug, Clone, PartialEq)]
121pub struct OffsetDeleteResponsePartition {
122    /// The partition index.
123    ///
124    /// Supported API versions: 0
125    pub partition_index: i32,
126
127    /// The error code, or 0 if there was no error.
128    ///
129    /// Supported API versions: 0
130    pub error_code: i16,
131}
132
133impl OffsetDeleteResponsePartition {
134    /// Sets `partition_index` to the passed value.
135    ///
136    /// The partition index.
137    ///
138    /// Supported API versions: 0
139    pub fn with_partition_index(mut self, value: i32) -> Self {
140        self.partition_index = value;
141        self
142    }
143    /// Sets `error_code` to the passed value.
144    ///
145    /// The error code, or 0 if there was no error.
146    ///
147    /// Supported API versions: 0
148    pub fn with_error_code(mut self, value: i16) -> Self {
149        self.error_code = value;
150        self
151    }
152}
153
154#[cfg(feature = "broker")]
155impl Encodable for OffsetDeleteResponsePartition {
156    fn encode<B: ByteBufMut>(&self, buf: &mut B, version: i16) -> Result<()> {
157        types::Int32.encode(buf, &self.partition_index)?;
158        types::Int16.encode(buf, &self.error_code)?;
159
160        Ok(())
161    }
162    fn compute_size(&self, version: i16) -> Result<usize> {
163        let mut total_size = 0;
164        total_size += types::Int32.compute_size(&self.partition_index)?;
165        total_size += types::Int16.compute_size(&self.error_code)?;
166
167        Ok(total_size)
168    }
169}
170
171#[cfg(feature = "client")]
172impl Decodable for OffsetDeleteResponsePartition {
173    fn decode<B: ByteBuf>(buf: &mut B, version: i16) -> Result<Self> {
174        let partition_index = types::Int32.decode(buf)?;
175        let error_code = types::Int16.decode(buf)?;
176        Ok(Self {
177            partition_index,
178            error_code,
179        })
180    }
181}
182
183impl Default for OffsetDeleteResponsePartition {
184    fn default() -> Self {
185        Self {
186            partition_index: 0,
187            error_code: 0,
188        }
189    }
190}
191
192impl Message for OffsetDeleteResponsePartition {
193    const VERSIONS: VersionRange = VersionRange { min: 0, max: 0 };
194    const DEPRECATED_VERSIONS: Option<VersionRange> = None;
195}
196
197/// Valid versions: 0
198#[non_exhaustive]
199#[derive(Debug, Clone, PartialEq)]
200pub struct OffsetDeleteResponseTopic {
201    /// The topic name.
202    ///
203    /// Supported API versions: 0
204    pub name: super::TopicName,
205
206    /// The responses for each partition in the topic.
207    ///
208    /// Supported API versions: 0
209    pub partitions: Vec<OffsetDeleteResponsePartition>,
210}
211
212impl OffsetDeleteResponseTopic {
213    /// Sets `name` to the passed value.
214    ///
215    /// The topic name.
216    ///
217    /// Supported API versions: 0
218    pub fn with_name(mut self, value: super::TopicName) -> Self {
219        self.name = value;
220        self
221    }
222    /// Sets `partitions` to the passed value.
223    ///
224    /// The responses for each partition in the topic.
225    ///
226    /// Supported API versions: 0
227    pub fn with_partitions(mut self, value: Vec<OffsetDeleteResponsePartition>) -> Self {
228        self.partitions = value;
229        self
230    }
231}
232
233#[cfg(feature = "broker")]
234impl Encodable for OffsetDeleteResponseTopic {
235    fn encode<B: ByteBufMut>(&self, buf: &mut B, version: i16) -> Result<()> {
236        types::String.encode(buf, &self.name)?;
237        types::Array(types::Struct { version }).encode(buf, &self.partitions)?;
238
239        Ok(())
240    }
241    fn compute_size(&self, version: i16) -> Result<usize> {
242        let mut total_size = 0;
243        total_size += types::String.compute_size(&self.name)?;
244        total_size += types::Array(types::Struct { version }).compute_size(&self.partitions)?;
245
246        Ok(total_size)
247    }
248}
249
250#[cfg(feature = "client")]
251impl Decodable for OffsetDeleteResponseTopic {
252    fn decode<B: ByteBuf>(buf: &mut B, version: i16) -> Result<Self> {
253        let name = types::String.decode(buf)?;
254        let partitions = types::Array(types::Struct { version }).decode(buf)?;
255        Ok(Self { name, partitions })
256    }
257}
258
259impl Default for OffsetDeleteResponseTopic {
260    fn default() -> Self {
261        Self {
262            name: Default::default(),
263            partitions: Default::default(),
264        }
265    }
266}
267
268impl Message for OffsetDeleteResponseTopic {
269    const VERSIONS: VersionRange = VersionRange { min: 0, max: 0 };
270    const DEPRECATED_VERSIONS: Option<VersionRange> = None;
271}
272
273impl HeaderVersion for OffsetDeleteResponse {
274    fn header_version(version: i16) -> i16 {
275        0
276    }
277}