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