Skip to main content

kacrab_protocol/generated/
delete_share_group_state_request.rs

1//! Generated from DeleteShareGroupStateRequest.json - DO NOT EDIT
2#![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 DeleteShareGroupStateRequestData {
17    /// The group identifier.
18    pub group_id: KafkaString,
19    /// The data for the topics.
20    pub topics: Vec<DeleteStateData>,
21    pub _unknown_tagged_fields: Vec<RawTaggedField>,
22}
23impl Default for DeleteShareGroupStateRequestData {
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 DeleteShareGroupStateRequestData {
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<DeleteStateData>) -> 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(86, 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(DeleteStateData::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(86, 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(86, 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 DeleteStateData {
103    /// The topic identifier.
104    pub topic_id: KafkaUuid,
105    /// The data for the partitions.
106    pub partitions: Vec<PartitionData>,
107    pub _unknown_tagged_fields: Vec<RawTaggedField>,
108}
109impl Default for DeleteStateData {
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 DeleteStateData {
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    /// The partition index.
181    pub partition: i32,
182    pub _unknown_tagged_fields: Vec<RawTaggedField>,
183}
184impl Default for PartitionData {
185    fn default() -> Self {
186        Self {
187            partition: 0_i32,
188            _unknown_tagged_fields: Vec::new(),
189        }
190    }
191}
192impl PartitionData {
193    pub fn with_partition(mut self, value: i32) -> Self {
194        self.partition = value;
195        self
196    }
197    pub fn read(buf: &mut Bytes, _version: i16) -> Result<Self> {
198        let partition;
199        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
200        partition = read_i32(buf)?;
201        let tagged_fields = read_tagged_fields(buf)?;
202        for field in &tagged_fields {
203            match field.tag {
204                _ => {
205                    _unknown_tagged_fields.push(field.clone());
206                },
207            }
208        }
209        Ok(Self {
210            partition,
211            _unknown_tagged_fields,
212        })
213    }
214    pub fn write(&self, buf: &mut BytesMut, _version: i16) -> Result<()> {
215        write_i32(buf, self.partition);
216        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
217        all_tags.sort_by_key(|f| f.tag);
218        write_tagged_fields(buf, &all_tags)?;
219        Ok(())
220    }
221    pub fn encoded_len(&self, _version: i16) -> Result<usize> {
222        let mut len: usize = 0;
223        len += 4;
224        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
225        all_tags.sort_by_key(|f| f.tag);
226        len += tagged_fields_len(&all_tags)?;
227        Ok(len)
228    }
229}