kacrab_protocol/generated/
describe_topic_partitions_request.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 DescribeTopicPartitionsRequestData {
17 pub topics: Vec<TopicRequest>,
19 pub response_partition_limit: i32,
21 pub cursor: Option<Box<Cursor>>,
23 pub _unknown_tagged_fields: Vec<RawTaggedField>,
24}
25impl Default for DescribeTopicPartitionsRequestData {
26 fn default() -> Self {
27 Self {
28 topics: Vec::new(),
29 response_partition_limit: 2000i32,
30 cursor: None,
31 _unknown_tagged_fields: Vec::new(),
32 }
33 }
34}
35impl DescribeTopicPartitionsRequestData {
36 pub fn with_topics(mut self, value: Vec<TopicRequest>) -> Self {
37 self.topics = value;
38 self
39 }
40 pub fn with_response_partition_limit(mut self, value: i32) -> Self {
41 self.response_partition_limit = value;
42 self
43 }
44 pub fn with_cursor(mut self, value: Option<Box<Cursor>>) -> Self {
45 self.cursor = value;
46 self
47 }
48 pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
49 if version < 0 || version > 0 {
50 return Err(UnsupportedVersion::new(75, version).into());
51 }
52 let topics;
53 let response_partition_limit;
54 let cursor;
55 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
56 topics = {
57 let len = read_compact_array_length(buf)?;
58 let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
59 for _ in 0..len {
60 arr.push(TopicRequest::read(buf, version)?);
61 }
62 arr
63 };
64 response_partition_limit = read_i32(buf)?;
65 cursor = {
66 let marker = read_i8(buf)?;
67 if marker < 0 {
68 None
69 } else {
70 Some(Box::new(Cursor::read(buf, version)?))
71 }
72 };
73 let tagged_fields = read_tagged_fields(buf)?;
74 for field in &tagged_fields {
75 match field.tag {
76 _ => {
77 _unknown_tagged_fields.push(field.clone());
78 },
79 }
80 }
81 Ok(Self {
82 topics,
83 response_partition_limit,
84 cursor,
85 _unknown_tagged_fields,
86 })
87 }
88 pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
89 if version < 0 || version > 0 {
90 return Err(UnsupportedVersion::new(75, version).into());
91 }
92 write_compact_array_length(buf, self.topics.len() as i32);
93 for el in &self.topics {
94 el.write(buf, version)?;
95 }
96 write_i32(buf, self.response_partition_limit);
97 match &self.cursor {
98 None => {
99 write_i8(buf, -1);
100 },
101 Some(v) => {
102 write_i8(buf, 1);
103 v.write(buf, version)?;
104 },
105 }
106 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
107 all_tags.sort_by_key(|f| f.tag);
108 write_tagged_fields(buf, &all_tags)?;
109 Ok(())
110 }
111 pub fn encoded_len(&self, version: i16) -> Result<usize> {
112 if version < 0 || version > 0 {
113 return Err(UnsupportedVersion::new(75, version).into());
114 }
115 let mut len: usize = 0;
116 len += compact_array_length_len(self.topics.len() as i32);
117 for el in &self.topics {
118 len += el.encoded_len(version)?;
119 }
120 len += 4;
121 match &self.cursor {
122 None => {
123 len += 1;
124 },
125 Some(v) => {
126 len += 1;
127 len += v.encoded_len(version)?;
128 },
129 }
130 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
131 all_tags.sort_by_key(|f| f.tag);
132 len += tagged_fields_len(&all_tags)?;
133 Ok(len)
134 }
135}
136#[derive(Debug, Clone, PartialEq)]
137pub struct TopicRequest {
138 pub name: KafkaString,
140 pub _unknown_tagged_fields: Vec<RawTaggedField>,
141}
142impl Default for TopicRequest {
143 fn default() -> Self {
144 Self {
145 name: KafkaString::default(),
146 _unknown_tagged_fields: Vec::new(),
147 }
148 }
149}
150impl TopicRequest {
151 pub fn with_name(mut self, value: KafkaString) -> Self {
152 self.name = value;
153 self
154 }
155 pub fn read(buf: &mut Bytes, _version: i16) -> Result<Self> {
156 let name;
157 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
158 name = read_compact_string(buf)?;
159 let tagged_fields = read_tagged_fields(buf)?;
160 for field in &tagged_fields {
161 match field.tag {
162 _ => {
163 _unknown_tagged_fields.push(field.clone());
164 },
165 }
166 }
167 Ok(Self {
168 name,
169 _unknown_tagged_fields,
170 })
171 }
172 pub fn write(&self, buf: &mut BytesMut, _version: i16) -> Result<()> {
173 write_compact_string(buf, &self.name)?;
174 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
175 all_tags.sort_by_key(|f| f.tag);
176 write_tagged_fields(buf, &all_tags)?;
177 Ok(())
178 }
179 pub fn encoded_len(&self, _version: i16) -> Result<usize> {
180 let mut len: usize = 0;
181 len += compact_string_len(&self.name)?;
182 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
183 all_tags.sort_by_key(|f| f.tag);
184 len += tagged_fields_len(&all_tags)?;
185 Ok(len)
186 }
187}
188#[derive(Debug, Clone, PartialEq)]
189pub struct Cursor {
190 pub topic_name: KafkaString,
192 pub partition_index: i32,
194 pub _unknown_tagged_fields: Vec<RawTaggedField>,
195}
196impl Default for Cursor {
197 fn default() -> Self {
198 Self {
199 topic_name: KafkaString::default(),
200 partition_index: 0_i32,
201 _unknown_tagged_fields: Vec::new(),
202 }
203 }
204}
205impl Cursor {
206 pub fn with_topic_name(mut self, value: KafkaString) -> Self {
207 self.topic_name = value;
208 self
209 }
210 pub fn with_partition_index(mut self, value: i32) -> Self {
211 self.partition_index = value;
212 self
213 }
214 pub fn read(buf: &mut Bytes, _version: i16) -> Result<Self> {
215 let topic_name;
216 let partition_index;
217 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
218 topic_name = read_compact_string(buf)?;
219 partition_index = read_i32(buf)?;
220 let tagged_fields = read_tagged_fields(buf)?;
221 for field in &tagged_fields {
222 match field.tag {
223 _ => {
224 _unknown_tagged_fields.push(field.clone());
225 },
226 }
227 }
228 Ok(Self {
229 topic_name,
230 partition_index,
231 _unknown_tagged_fields,
232 })
233 }
234 pub fn write(&self, buf: &mut BytesMut, _version: i16) -> Result<()> {
235 write_compact_string(buf, &self.topic_name)?;
236 write_i32(buf, self.partition_index);
237 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
238 all_tags.sort_by_key(|f| f.tag);
239 write_tagged_fields(buf, &all_tags)?;
240 Ok(())
241 }
242 pub fn encoded_len(&self, _version: i16) -> Result<usize> {
243 let mut len: usize = 0;
244 len += compact_string_len(&self.topic_name)?;
245 len += 4;
246 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
247 all_tags.sort_by_key(|f| f.tag);
248 len += tagged_fields_len(&all_tags)?;
249 Ok(len)
250 }
251}