Skip to main content

crabka_protocol/opt/rustwide/workdir/generated/
StreamsGroupDescribeResponse.owned.rs

1// AUTO-GENERATED by crabka-protocol-codegen against a9ce3221537b8653448750697915607dc7936cf3. Do not edit.
2
3use bytes::{Buf, BufMut};
4
5use crate::primitives::fixed::{get_bool, get_i16, get_i32, get_i8, put_bool, put_i16, put_i32};
6use crate::primitives::string_bytes::{
7    compact_nullable_string_len, compact_string_len, get_compact_nullable_string_owned,
8    get_compact_string_owned, get_nullable_string_owned, get_string_owned, nullable_string_len,
9    put_compact_nullable_string, put_compact_string, put_nullable_string, put_string,
10    string_len,
11};
12use crate::tagged_fields::{read_tagged_fields, tagged_fields_len, WriteTaggedFields};
13use crate::{Decode, Encode, ProtocolError, UnknownTaggedFields};
14
15pub const API_KEY: i16 = 89;
16pub const MIN_VERSION: i16 = 0;
17pub const MAX_VERSION: i16 = 0;
18pub const FLEXIBLE_MIN: i16 = 0;
19
20#[inline]
21fn is_flexible(version: i16) -> bool { version >= FLEXIBLE_MIN }
22
23#[derive(Debug, Clone, PartialEq, Eq, Default)]
24pub struct StreamsGroupDescribeResponse {
25    pub throttle_time_ms: i32,
26    pub groups: Vec<DescribedGroup>,
27    pub unknown_tagged_fields: UnknownTaggedFields,
28}
29
30impl Encode for StreamsGroupDescribeResponse {
31    fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
32        if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
33            return Err(ProtocolError::UnsupportedVersion { api_key: API_KEY, version });
34        }
35        let flex = is_flexible(version);
36        if version >= 0 { put_i32(buf, self.throttle_time_ms) }
37        if version >= 0 { { crate::primitives::array::put_array_len(buf, (self.groups).len(), flex); for it in &self.groups { it.encode(buf, version)?; } } }
38        if flex {
39            let tagged = WriteTaggedFields::new();
40            tagged.write(buf, &self.unknown_tagged_fields);
41        }
42        Ok(())
43    }
44    fn encoded_len(&self, version: i16) -> usize {
45        let flex = is_flexible(version);
46        let mut n: usize = 0;
47        if version >= 0 { n += 4; }
48        if version >= 0 { n += { let prefix = crate::primitives::array::array_len_prefix_len((self.groups).len(), flex); let body: usize = (self.groups).iter().map(|it| it.encoded_len(version)).sum(); prefix + body }; }
49        if flex {
50            let known_pairs: Vec<(u32, usize)> = Vec::new();
51            n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
52        }
53        n
54    }
55}
56
57impl<'de> Decode<'de> for StreamsGroupDescribeResponse {
58    fn decode<B: Buf>(buf: &mut B, version: i16) -> Result<Self, ProtocolError> {
59        if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
60            return Err(ProtocolError::UnsupportedVersion { api_key: API_KEY, version });
61        }
62        let flex = is_flexible(version);
63        let mut out = Self::default();
64        if version >= 0 { out.throttle_time_ms = get_i32(buf)?; }
65        if version >= 0 { out.groups = { let n = crate::primitives::array::get_array_len(buf, flex)?; let mut v = Vec::with_capacity(n); for _ in 0..n { v.push(DescribedGroup::decode(buf, version)?); } v }; }
66        if flex {
67            out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| {
68                Ok(false)
69            })?;
70        }
71        Ok(out)
72    }
73}
74
75#[derive(Debug, Clone, PartialEq, Eq)]
76pub struct DescribedGroup {
77    pub error_code: i16,
78    pub error_message: Option<String>,
79    pub group_id: String,
80    pub group_state: String,
81    pub group_epoch: i32,
82    pub assignment_epoch: i32,
83    pub topology: Option<Topology>,
84    pub members: Vec<Member>,
85    pub authorized_operations: i32,
86    pub unknown_tagged_fields: UnknownTaggedFields,
87}
88
89impl Default for DescribedGroup {
90    fn default() -> Self {
91        Self {
92            error_code: 0i16,
93            error_message: None,
94            group_id: String::new(),
95            group_state: String::new(),
96            group_epoch: 0i32,
97            assignment_epoch: 0i32,
98            topology: None,
99            members: Vec::new(),
100            authorized_operations: -2_147_483_648i32,
101            unknown_tagged_fields: Default::default(),
102        }
103    }
104}
105
106impl Encode for DescribedGroup {
107    fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
108        let flex = version >= 0;
109        if version >= 0 { put_i16(buf, self.error_code) }
110        if version >= 0 { if flex { put_compact_nullable_string(buf, self.error_message.as_deref()) } else { put_nullable_string(buf, self.error_message.as_deref()) } }
111        if version >= 0 { if flex { put_compact_string(buf, &self.group_id) } else { put_string(buf, &self.group_id) } }
112        if version >= 0 { if flex { put_compact_string(buf, &self.group_state) } else { put_string(buf, &self.group_state) } }
113        if version >= 0 { put_i32(buf, self.group_epoch) }
114        if version >= 0 { put_i32(buf, self.assignment_epoch) }
115        if version >= 0 { match &self.topology { None => { buf.put_i8(-1); }, Some(v) => { buf.put_i8(1); v.encode(buf, version)?; } } }
116        if version >= 0 { { crate::primitives::array::put_array_len(buf, (self.members).len(), flex); for it in &self.members { it.encode(buf, version)?; } } }
117        if version >= 0 { put_i32(buf, self.authorized_operations) }
118        if flex {
119            let tagged = WriteTaggedFields::new();
120            tagged.write(buf, &self.unknown_tagged_fields);
121        }
122        Ok(())
123    }
124    fn encoded_len(&self, version: i16) -> usize {
125        let flex = version >= 0;
126        let mut n: usize = 0;
127        if version >= 0 { n += 2; }
128        if version >= 0 { n += if flex { compact_nullable_string_len(self.error_message.as_deref()) } else { nullable_string_len(self.error_message.as_deref()) }; }
129        if version >= 0 { n += if flex { compact_string_len(&self.group_id) } else { string_len(&self.group_id) }; }
130        if version >= 0 { n += if flex { compact_string_len(&self.group_state) } else { string_len(&self.group_state) }; }
131        if version >= 0 { n += 4; }
132        if version >= 0 { n += 4; }
133        if version >= 0 { n += 1 + self.topology.as_ref().map_or(0, |v| v.encoded_len(version)); }
134        if version >= 0 { n += { let prefix = crate::primitives::array::array_len_prefix_len((self.members).len(), flex); let body: usize = (self.members).iter().map(|it| it.encoded_len(version)).sum(); prefix + body }; }
135        if version >= 0 { n += 4; }
136        if flex {
137            let known_pairs: Vec<(u32, usize)> = Vec::new();
138            n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
139        }
140        n
141    }
142}
143
144impl<'de> Decode<'de> for DescribedGroup {
145    fn decode<B: Buf>(buf: &mut B, version: i16) -> Result<Self, ProtocolError> {
146        let flex = version >= 0;
147        let mut out = Self::default();
148        if version >= 0 { out.error_code = get_i16(buf)?; }
149        if version >= 0 { out.error_message = if flex { get_compact_nullable_string_owned(buf)? } else { get_nullable_string_owned(buf)? }; }
150        if version >= 0 { out.group_id = if flex { get_compact_string_owned(buf)? } else { get_string_owned(buf)? }; }
151        if version >= 0 { out.group_state = if flex { get_compact_string_owned(buf)? } else { get_string_owned(buf)? }; }
152        if version >= 0 { out.group_epoch = get_i32(buf)?; }
153        if version >= 0 { out.assignment_epoch = get_i32(buf)?; }
154        if version >= 0 { out.topology = if get_i8(buf)? < 0 { None } else { Some(Topology::decode(buf, version)?) }; }
155        if version >= 0 { out.members = { let n = crate::primitives::array::get_array_len(buf, flex)?; let mut v = Vec::with_capacity(n); for _ in 0..n { v.push(Member::decode(buf, version)?); } v }; }
156        if version >= 0 { out.authorized_operations = get_i32(buf)?; }
157        if flex {
158            out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| {
159                Ok(false)
160            })?;
161        }
162        Ok(out)
163    }
164}
165
166#[derive(Debug, Clone, PartialEq, Eq, Default)]
167pub struct Topology {
168    pub epoch: i32,
169    pub subtopologies: Option<Vec<Subtopology>>,
170    pub unknown_tagged_fields: UnknownTaggedFields,
171}
172
173impl Encode for Topology {
174    fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
175        let flex = version >= 0;
176        if version >= 0 { put_i32(buf, self.epoch) }
177        if version >= 0 { { let len = (self.subtopologies).as_ref().map(Vec::len); crate::primitives::array::put_nullable_array_len(buf, len, flex); if let Some(v) = &self.subtopologies { for it in v { it.encode(buf, version)?; } } } }
178        if flex {
179            let tagged = WriteTaggedFields::new();
180            tagged.write(buf, &self.unknown_tagged_fields);
181        }
182        Ok(())
183    }
184    fn encoded_len(&self, version: i16) -> usize {
185        let flex = version >= 0;
186        let mut n: usize = 0;
187        if version >= 0 { n += 4; }
188        if version >= 0 { n += { let opt: Option<&Vec<_>> = (self.subtopologies).as_ref(); let prefix = crate::primitives::array::nullable_array_len_prefix_len(opt.map(|v| v.len()), flex); let body: usize = opt.map_or(0, |v| v.iter().map(|it| it.encoded_len(version)).sum()); prefix + body }; }
189        if flex {
190            let known_pairs: Vec<(u32, usize)> = Vec::new();
191            n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
192        }
193        n
194    }
195}
196
197impl<'de> Decode<'de> for Topology {
198    fn decode<B: Buf>(buf: &mut B, version: i16) -> Result<Self, ProtocolError> {
199        let flex = version >= 0;
200        let mut out = Self::default();
201        if version >= 0 { out.epoch = get_i32(buf)?; }
202        if version >= 0 { out.subtopologies = { let opt = crate::primitives::array::get_nullable_array_len(buf, flex)?; match opt { None => None, Some(n) => { let mut v = Vec::with_capacity(n); for _ in 0..n { v.push(Subtopology::decode(buf, version)?); } Some(v) } } }; }
203        if flex {
204            out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| {
205                Ok(false)
206            })?;
207        }
208        Ok(out)
209    }
210}
211
212#[derive(Debug, Clone, PartialEq, Eq, Default)]
213pub struct Subtopology {
214    pub subtopology_id: String,
215    pub source_topics: Vec<String>,
216    pub repartition_sink_topics: Vec<String>,
217    pub state_changelog_topics: Vec<super::common::topic_info::TopicInfo>,
218    pub repartition_source_topics: Vec<super::common::topic_info::TopicInfo>,
219    pub unknown_tagged_fields: UnknownTaggedFields,
220}
221
222impl Encode for Subtopology {
223    fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
224        let flex = version >= 0;
225        if version >= 0 { if flex { put_compact_string(buf, &self.subtopology_id) } else { put_string(buf, &self.subtopology_id) } }
226        if version >= 0 { { crate::primitives::array::put_array_len(buf, (self.source_topics).len(), flex); for it in &self.source_topics { if flex { put_compact_string(buf, &*it) } else { put_string(buf, &*it) }; } } }
227        if version >= 0 { { crate::primitives::array::put_array_len(buf, (self.repartition_sink_topics).len(), flex); for it in &self.repartition_sink_topics { if flex { put_compact_string(buf, &*it) } else { put_string(buf, &*it) }; } } }
228        if version >= 0 { { crate::primitives::array::put_array_len(buf, (self.state_changelog_topics).len(), flex); for it in &self.state_changelog_topics { it.encode(buf, version)?; } } }
229        if version >= 0 { { crate::primitives::array::put_array_len(buf, (self.repartition_source_topics).len(), flex); for it in &self.repartition_source_topics { it.encode(buf, version)?; } } }
230        if flex {
231            let tagged = WriteTaggedFields::new();
232            tagged.write(buf, &self.unknown_tagged_fields);
233        }
234        Ok(())
235    }
236    fn encoded_len(&self, version: i16) -> usize {
237        let flex = version >= 0;
238        let mut n: usize = 0;
239        if version >= 0 { n += if flex { compact_string_len(&self.subtopology_id) } else { string_len(&self.subtopology_id) }; }
240        if version >= 0 { n += { let prefix = crate::primitives::array::array_len_prefix_len((self.source_topics).len(), flex); let body: usize = (self.source_topics).iter().map(|it| if flex { compact_string_len(&*it) } else { string_len(&*it) }).sum(); prefix + body }; }
241        if version >= 0 { n += { let prefix = crate::primitives::array::array_len_prefix_len((self.repartition_sink_topics).len(), flex); let body: usize = (self.repartition_sink_topics).iter().map(|it| if flex { compact_string_len(&*it) } else { string_len(&*it) }).sum(); prefix + body }; }
242        if version >= 0 { n += { let prefix = crate::primitives::array::array_len_prefix_len((self.state_changelog_topics).len(), flex); let body: usize = (self.state_changelog_topics).iter().map(|it| it.encoded_len(version)).sum(); prefix + body }; }
243        if version >= 0 { n += { let prefix = crate::primitives::array::array_len_prefix_len((self.repartition_source_topics).len(), flex); let body: usize = (self.repartition_source_topics).iter().map(|it| it.encoded_len(version)).sum(); prefix + body }; }
244        if flex {
245            let known_pairs: Vec<(u32, usize)> = Vec::new();
246            n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
247        }
248        n
249    }
250}
251
252impl<'de> Decode<'de> for Subtopology {
253    fn decode<B: Buf>(buf: &mut B, version: i16) -> Result<Self, ProtocolError> {
254        let flex = version >= 0;
255        let mut out = Self::default();
256        if version >= 0 { out.subtopology_id = if flex { get_compact_string_owned(buf)? } else { get_string_owned(buf)? }; }
257        if version >= 0 { out.source_topics = { let n = crate::primitives::array::get_array_len(buf, flex)?; let mut v = Vec::with_capacity(n); for _ in 0..n { v.push(if flex { get_compact_string_owned(buf)? } else { get_string_owned(buf)? }); } v }; }
258        if version >= 0 { out.repartition_sink_topics = { let n = crate::primitives::array::get_array_len(buf, flex)?; let mut v = Vec::with_capacity(n); for _ in 0..n { v.push(if flex { get_compact_string_owned(buf)? } else { get_string_owned(buf)? }); } v }; }
259        if version >= 0 { out.state_changelog_topics = { let n = crate::primitives::array::get_array_len(buf, flex)?; let mut v = Vec::with_capacity(n); for _ in 0..n { v.push(super::common::topic_info::TopicInfo::decode(buf, version)?); } v }; }
260        if version >= 0 { out.repartition_source_topics = { let n = crate::primitives::array::get_array_len(buf, flex)?; let mut v = Vec::with_capacity(n); for _ in 0..n { v.push(super::common::topic_info::TopicInfo::decode(buf, version)?); } v }; }
261        if flex {
262            out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| {
263                Ok(false)
264            })?;
265        }
266        Ok(out)
267    }
268}
269
270#[derive(Debug, Clone, PartialEq, Eq, Default)]
271pub struct Member {
272    pub member_id: String,
273    pub member_epoch: i32,
274    pub instance_id: Option<String>,
275    pub rack_id: Option<String>,
276    pub client_id: String,
277    pub client_host: String,
278    pub topology_epoch: i32,
279    pub process_id: String,
280    pub user_endpoint: Option<super::common::endpoint::Endpoint>,
281    pub client_tags: Vec<super::common::key_value::KeyValue>,
282    pub task_offsets: Vec<super::common::task_offset::TaskOffset>,
283    pub task_end_offsets: Vec<super::common::task_offset::TaskOffset>,
284    pub assignment: super::common::assignment::Assignment,
285    pub target_assignment: super::common::assignment::Assignment,
286    pub is_classic: bool,
287    pub unknown_tagged_fields: UnknownTaggedFields,
288}
289
290impl Encode for Member {
291    fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
292        let flex = version >= 0;
293        if version >= 0 { if flex { put_compact_string(buf, &self.member_id) } else { put_string(buf, &self.member_id) } }
294        if version >= 0 { put_i32(buf, self.member_epoch) }
295        if version >= 0 { if flex { put_compact_nullable_string(buf, self.instance_id.as_deref()) } else { put_nullable_string(buf, self.instance_id.as_deref()) } }
296        if version >= 0 { if flex { put_compact_nullable_string(buf, self.rack_id.as_deref()) } else { put_nullable_string(buf, self.rack_id.as_deref()) } }
297        if version >= 0 { if flex { put_compact_string(buf, &self.client_id) } else { put_string(buf, &self.client_id) } }
298        if version >= 0 { if flex { put_compact_string(buf, &self.client_host) } else { put_string(buf, &self.client_host) } }
299        if version >= 0 { put_i32(buf, self.topology_epoch) }
300        if version >= 0 { if flex { put_compact_string(buf, &self.process_id) } else { put_string(buf, &self.process_id) } }
301        if version >= 0 { match &self.user_endpoint { None => { buf.put_i8(-1); }, Some(v) => { buf.put_i8(1); v.encode(buf, version)?; } } }
302        if version >= 0 { { crate::primitives::array::put_array_len(buf, (self.client_tags).len(), flex); for it in &self.client_tags { it.encode(buf, version)?; } } }
303        if version >= 0 { { crate::primitives::array::put_array_len(buf, (self.task_offsets).len(), flex); for it in &self.task_offsets { it.encode(buf, version)?; } } }
304        if version >= 0 { { crate::primitives::array::put_array_len(buf, (self.task_end_offsets).len(), flex); for it in &self.task_end_offsets { it.encode(buf, version)?; } } }
305        if version >= 0 { self.assignment.encode(buf, version)? }
306        if version >= 0 { self.target_assignment.encode(buf, version)? }
307        if version >= 0 { put_bool(buf, self.is_classic) }
308        if flex {
309            let tagged = WriteTaggedFields::new();
310            tagged.write(buf, &self.unknown_tagged_fields);
311        }
312        Ok(())
313    }
314    fn encoded_len(&self, version: i16) -> usize {
315        let flex = version >= 0;
316        let mut n: usize = 0;
317        if version >= 0 { n += if flex { compact_string_len(&self.member_id) } else { string_len(&self.member_id) }; }
318        if version >= 0 { n += 4; }
319        if version >= 0 { n += if flex { compact_nullable_string_len(self.instance_id.as_deref()) } else { nullable_string_len(self.instance_id.as_deref()) }; }
320        if version >= 0 { n += if flex { compact_nullable_string_len(self.rack_id.as_deref()) } else { nullable_string_len(self.rack_id.as_deref()) }; }
321        if version >= 0 { n += if flex { compact_string_len(&self.client_id) } else { string_len(&self.client_id) }; }
322        if version >= 0 { n += if flex { compact_string_len(&self.client_host) } else { string_len(&self.client_host) }; }
323        if version >= 0 { n += 4; }
324        if version >= 0 { n += if flex { compact_string_len(&self.process_id) } else { string_len(&self.process_id) }; }
325        if version >= 0 { n += 1 + self.user_endpoint.as_ref().map_or(0, |v| v.encoded_len(version)); }
326        if version >= 0 { n += { let prefix = crate::primitives::array::array_len_prefix_len((self.client_tags).len(), flex); let body: usize = (self.client_tags).iter().map(|it| it.encoded_len(version)).sum(); prefix + body }; }
327        if version >= 0 { n += { let prefix = crate::primitives::array::array_len_prefix_len((self.task_offsets).len(), flex); let body: usize = (self.task_offsets).iter().map(|it| it.encoded_len(version)).sum(); prefix + body }; }
328        if version >= 0 { n += { let prefix = crate::primitives::array::array_len_prefix_len((self.task_end_offsets).len(), flex); let body: usize = (self.task_end_offsets).iter().map(|it| it.encoded_len(version)).sum(); prefix + body }; }
329        if version >= 0 { n += self.assignment.encoded_len(version); }
330        if version >= 0 { n += self.target_assignment.encoded_len(version); }
331        if version >= 0 { n += 1; }
332        if flex {
333            let known_pairs: Vec<(u32, usize)> = Vec::new();
334            n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
335        }
336        n
337    }
338}
339
340impl<'de> Decode<'de> for Member {
341    fn decode<B: Buf>(buf: &mut B, version: i16) -> Result<Self, ProtocolError> {
342        let flex = version >= 0;
343        let mut out = Self::default();
344        if version >= 0 { out.member_id = if flex { get_compact_string_owned(buf)? } else { get_string_owned(buf)? }; }
345        if version >= 0 { out.member_epoch = get_i32(buf)?; }
346        if version >= 0 { out.instance_id = if flex { get_compact_nullable_string_owned(buf)? } else { get_nullable_string_owned(buf)? }; }
347        if version >= 0 { out.rack_id = if flex { get_compact_nullable_string_owned(buf)? } else { get_nullable_string_owned(buf)? }; }
348        if version >= 0 { out.client_id = if flex { get_compact_string_owned(buf)? } else { get_string_owned(buf)? }; }
349        if version >= 0 { out.client_host = if flex { get_compact_string_owned(buf)? } else { get_string_owned(buf)? }; }
350        if version >= 0 { out.topology_epoch = get_i32(buf)?; }
351        if version >= 0 { out.process_id = if flex { get_compact_string_owned(buf)? } else { get_string_owned(buf)? }; }
352        if version >= 0 { out.user_endpoint = if get_i8(buf)? < 0 { None } else { Some(super::common::endpoint::Endpoint::decode(buf, version)?) }; }
353        if version >= 0 { out.client_tags = { let n = crate::primitives::array::get_array_len(buf, flex)?; let mut v = Vec::with_capacity(n); for _ in 0..n { v.push(super::common::key_value::KeyValue::decode(buf, version)?); } v }; }
354        if version >= 0 { out.task_offsets = { let n = crate::primitives::array::get_array_len(buf, flex)?; let mut v = Vec::with_capacity(n); for _ in 0..n { v.push(super::common::task_offset::TaskOffset::decode(buf, version)?); } v }; }
355        if version >= 0 { out.task_end_offsets = { let n = crate::primitives::array::get_array_len(buf, flex)?; let mut v = Vec::with_capacity(n); for _ in 0..n { v.push(super::common::task_offset::TaskOffset::decode(buf, version)?); } v }; }
356        if version >= 0 { out.assignment = super::common::assignment::Assignment::decode(buf, version)?; }
357        if version >= 0 { out.target_assignment = super::common::assignment::Assignment::decode(buf, version)?; }
358        if version >= 0 { out.is_classic = get_bool(buf)?; }
359        if flex {
360            out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| {
361                Ok(false)
362            })?;
363        }
364        Ok(out)
365    }
366}
367
368/// Default JSON payload matching `Self::default()` for JVM oracle differential testing.
369/// Only includes fields valid for the given version.
370#[must_use]
371#[allow(unused_comparisons)]
372pub fn default_json(version: i16) -> ::serde_json::Value {
373    let mut obj = ::serde_json::Map::new();
374    obj.insert("throttleTimeMs".to_string(), ::serde_json::json!(0));
375    obj.insert("groups".to_string(), ::serde_json::Value::Array(vec![]));
376    ::serde_json::Value::Object(obj)
377}