kacrab_protocol/generated/
offset_delete_response.rs1#![allow(
3 missing_docs,
4 clippy::all,
5 clippy::pedantic,
6 clippy::nursery,
7 clippy::arithmetic_side_effects,
8 reason = "Generated protocol modules mirror Kafka's schema shape and intentionally trade \
9 hand-written lint style for reproducible wire-code output."
10)]
11use bytes::{Bytes, BytesMut};
12
13use crate::*;
14
15#[derive(Debug, Clone, PartialEq)]
16pub struct OffsetDeleteResponseData {
17 pub error_code: i16,
19 pub throttle_time_ms: i32,
22 pub topics: Vec<OffsetDeleteResponseTopic>,
24 pub _unknown_tagged_fields: Vec<RawTaggedField>,
25}
26impl Default for OffsetDeleteResponseData {
27 fn default() -> Self {
28 Self {
29 error_code: 0_i16,
30 throttle_time_ms: 0_i32,
31 topics: Vec::new(),
32 _unknown_tagged_fields: Vec::new(),
33 }
34 }
35}
36impl OffsetDeleteResponseData {
37 pub fn with_error_code(mut self, value: i16) -> Self {
38 self.error_code = value;
39 self
40 }
41 pub fn with_throttle_time_ms(mut self, value: i32) -> Self {
42 self.throttle_time_ms = value;
43 self
44 }
45 pub fn with_topics(mut self, value: Vec<OffsetDeleteResponseTopic>) -> Self {
46 self.topics = value;
47 self
48 }
49 pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
50 if version < 0 || version > 0 {
51 return Err(UnsupportedVersion::new(47, version).into());
52 }
53 let error_code;
54 let throttle_time_ms;
55 let topics;
56 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
57 error_code = read_i16(buf)?;
58 throttle_time_ms = read_i32(buf)?;
59 topics = {
60 let len = read_array_length(buf)?;
61 let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
62 for _ in 0..len {
63 arr.push(OffsetDeleteResponseTopic::read(buf, version)?);
64 }
65 arr
66 };
67 Ok(Self {
68 error_code,
69 throttle_time_ms,
70 topics,
71 _unknown_tagged_fields,
72 })
73 }
74 pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
75 if version < 0 || version > 0 {
76 return Err(UnsupportedVersion::new(47, version).into());
77 }
78 write_i16(buf, self.error_code);
79 write_i32(buf, self.throttle_time_ms);
80 write_array_length(buf, self.topics.len() as i32);
81 for el in &self.topics {
82 el.write(buf, version)?;
83 }
84 Ok(())
85 }
86 pub fn encoded_len(&self, version: i16) -> Result<usize> {
87 if version < 0 || version > 0 {
88 return Err(UnsupportedVersion::new(47, version).into());
89 }
90 let mut len: usize = 0;
91 len += 2;
92 len += 4;
93 len += array_length_len();
94 for el in &self.topics {
95 len += el.encoded_len(version)?;
96 }
97 Ok(len)
98 }
99}
100#[derive(Debug, Clone, PartialEq)]
101pub struct OffsetDeleteResponseTopic {
102 pub name: KafkaString,
104 pub partitions: Vec<OffsetDeleteResponsePartition>,
106 pub _unknown_tagged_fields: Vec<RawTaggedField>,
107}
108impl Default for OffsetDeleteResponseTopic {
109 fn default() -> Self {
110 Self {
111 name: KafkaString::default(),
112 partitions: Vec::new(),
113 _unknown_tagged_fields: Vec::new(),
114 }
115 }
116}
117impl OffsetDeleteResponseTopic {
118 pub fn with_name(mut self, value: KafkaString) -> Self {
119 self.name = value;
120 self
121 }
122 pub fn with_partitions(mut self, value: Vec<OffsetDeleteResponsePartition>) -> Self {
123 self.partitions = value;
124 self
125 }
126 pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
127 let name;
128 let partitions;
129 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
130 name = read_string(buf)?;
131 partitions = {
132 let len = read_array_length(buf)?;
133 let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
134 for _ in 0..len {
135 arr.push(OffsetDeleteResponsePartition::read(buf, version)?);
136 }
137 arr
138 };
139 Ok(Self {
140 name,
141 partitions,
142 _unknown_tagged_fields,
143 })
144 }
145 pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
146 write_string(buf, &self.name)?;
147 write_array_length(buf, self.partitions.len() as i32);
148 for el in &self.partitions {
149 el.write(buf, version)?;
150 }
151 Ok(())
152 }
153 pub fn encoded_len(&self, version: i16) -> Result<usize> {
154 let mut len: usize = 0;
155 len += string_len(&self.name)?;
156 len += array_length_len();
157 for el in &self.partitions {
158 len += el.encoded_len(version)?;
159 }
160 Ok(len)
161 }
162}
163#[derive(Debug, Clone, PartialEq)]
164pub struct OffsetDeleteResponsePartition {
165 pub partition_index: i32,
167 pub error_code: i16,
169 pub _unknown_tagged_fields: Vec<RawTaggedField>,
170}
171impl Default for OffsetDeleteResponsePartition {
172 fn default() -> Self {
173 Self {
174 partition_index: 0_i32,
175 error_code: 0_i16,
176 _unknown_tagged_fields: Vec::new(),
177 }
178 }
179}
180impl OffsetDeleteResponsePartition {
181 pub fn with_partition_index(mut self, value: i32) -> Self {
182 self.partition_index = value;
183 self
184 }
185 pub fn with_error_code(mut self, value: i16) -> Self {
186 self.error_code = value;
187 self
188 }
189 pub fn read(buf: &mut Bytes, _version: i16) -> Result<Self> {
190 let partition_index;
191 let error_code;
192 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
193 partition_index = read_i32(buf)?;
194 error_code = read_i16(buf)?;
195 Ok(Self {
196 partition_index,
197 error_code,
198 _unknown_tagged_fields,
199 })
200 }
201 pub fn write(&self, buf: &mut BytesMut, _version: i16) -> Result<()> {
202 write_i32(buf, self.partition_index);
203 write_i16(buf, self.error_code);
204 Ok(())
205 }
206 pub fn encoded_len(&self, _version: i16) -> Result<usize> {
207 let mut len: usize = 0;
208 len += 4;
209 len += 2;
210 Ok(len)
211 }
212}