kafka_protocol/messages/
offset_delete_response.rs1#![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#[non_exhaustive]
22#[derive(Debug, Clone, PartialEq)]
23pub struct OffsetDeleteResponse {
24 pub error_code: i16,
28
29 pub throttle_time_ms: i32,
33
34 pub topics: Vec<OffsetDeleteResponseTopic>,
38}
39
40impl OffsetDeleteResponse {
41 pub fn with_error_code(mut self, value: i16) -> Self {
47 self.error_code = value;
48 self
49 }
50 pub fn with_throttle_time_ms(mut self, value: i32) -> Self {
56 self.throttle_time_ms = value;
57 self
58 }
59 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#[non_exhaustive]
120#[derive(Debug, Clone, PartialEq)]
121pub struct OffsetDeleteResponsePartition {
122 pub partition_index: i32,
126
127 pub error_code: i16,
131}
132
133impl OffsetDeleteResponsePartition {
134 pub fn with_partition_index(mut self, value: i32) -> Self {
140 self.partition_index = value;
141 self
142 }
143 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#[non_exhaustive]
199#[derive(Debug, Clone, PartialEq)]
200pub struct OffsetDeleteResponseTopic {
201 pub name: super::TopicName,
205
206 pub partitions: Vec<OffsetDeleteResponsePartition>,
210}
211
212impl OffsetDeleteResponseTopic {
213 pub fn with_name(mut self, value: super::TopicName) -> Self {
219 self.name = value;
220 self
221 }
222 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}