kafka_wire_protocol/schema/share_group_describe_response/
v0.rs

1// This file was generated. Do not edit.
2
3use std::io::{Read, Result, Write};
4
5use serde::{Deserialize, Serialize};
6use uuid::Uuid;
7#[cfg(test)] use proptest_derive::Arbitrary;
8
9use crate::arrays::{read_array, write_array};
10use crate::markers::{ApiMessage, Response};
11use crate::readable_writable::{Readable, Writable};
12use crate::tagged_fields::{RawTaggedField, read_tagged_fields, write_tagged_fields};
13#[cfg(test)] use crate::test_utils::proptest_strategies;
14
15/// ShareGroupDescribeResponse, version 0.
16#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
17#[cfg_attr(test, derive(Arbitrary))]
18pub struct ShareGroupDescribeResponse {
19    /// The duration in milliseconds for which the request was throttled due to a quota violation, or zero if the request did not violate any quota.
20    pub throttle_time_ms: i32,
21    /// Each described group.
22    #[cfg_attr(test, proptest(strategy = "proptest_strategies::vec()"))]
23    pub groups: Vec<DescribedGroup>,
24    /// Unknown tagged fields.
25    #[cfg_attr(test, proptest(strategy = "proptest_strategies::unknown_tagged_fields()"))]
26    pub _unknown_tagged_fields: Vec<RawTaggedField>,
27}
28
29impl ApiMessage for ShareGroupDescribeResponse {
30    fn api_key(&self) -> i16 {
31        77
32    }
33    
34    fn version(&self) -> i16 {
35        0
36    }
37}
38
39impl Response for ShareGroupDescribeResponse { }
40
41impl Default for ShareGroupDescribeResponse {
42    fn default() -> Self {
43        ShareGroupDescribeResponse {
44            throttle_time_ms: 0_i32,
45            groups: Vec::<DescribedGroup>::new(),
46            _unknown_tagged_fields: Vec::new(),
47        }
48    }
49}
50
51impl ShareGroupDescribeResponse {
52    pub fn new(throttle_time_ms: i32, groups: Vec<DescribedGroup>) -> Self {
53        Self {
54            throttle_time_ms,
55            groups,
56            _unknown_tagged_fields: vec![],
57        }
58    }
59}
60
61#[cfg(test)]
62mod tests_share_group_describe_response_new_and_default {
63    use super::*;
64    
65    #[test]
66    fn test() {
67        let d = ShareGroupDescribeResponse::new(
68            0_i32,
69            Vec::<DescribedGroup>::new(),
70        );
71        assert_eq!(d, ShareGroupDescribeResponse::default());
72    }
73}
74
75impl Readable for ShareGroupDescribeResponse {
76    fn read(#[allow(unused)] input: &mut impl Read) -> Result<Self> {
77        let throttle_time_ms = i32::read(input)?;
78        let groups = read_array::<DescribedGroup>(input, "groups", true)?;
79        let tagged_fields_callback = |tag: i32, _: &[u8]| {
80            match tag {
81                _ => Ok(false)
82            }
83        };
84        let _unknown_tagged_fields = read_tagged_fields(input, tagged_fields_callback)?;
85        Ok(ShareGroupDescribeResponse {
86            throttle_time_ms, groups, _unknown_tagged_fields
87        })
88    }
89}
90
91impl Writable for ShareGroupDescribeResponse {
92    fn write(&self, #[allow(unused)] output: &mut impl Write) -> Result<()> {
93        self.throttle_time_ms.write(output)?;
94        write_array(output, "self.groups", &self.groups, true)?;
95        write_tagged_fields(output, &[], &self._unknown_tagged_fields)?;
96        Ok(())
97    }
98}
99
100/// DescribedGroup, version 0.
101#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
102#[cfg_attr(test, derive(Arbitrary))]
103pub struct DescribedGroup {
104    /// The describe error, or 0 if there was no error.
105    pub error_code: i16,
106    /// The top-level error message, or null if there was no error.
107    #[cfg_attr(test, proptest(strategy = "proptest_strategies::optional_string()"))]
108    pub error_message: Option<String>,
109    /// The group ID string.
110    #[cfg_attr(test, proptest(strategy = "proptest_strategies::string()"))]
111    pub group_id: String,
112    /// The group state string, or the empty string.
113    #[cfg_attr(test, proptest(strategy = "proptest_strategies::string()"))]
114    pub group_state: String,
115    /// The group epoch.
116    pub group_epoch: i32,
117    /// The assignment epoch.
118    pub assignment_epoch: i32,
119    /// The selected assignor.
120    #[cfg_attr(test, proptest(strategy = "proptest_strategies::string()"))]
121    pub assignor_name: String,
122    /// The members.
123    #[cfg_attr(test, proptest(strategy = "proptest_strategies::vec()"))]
124    pub members: Vec<Member>,
125    /// 32-bit bitfield to represent authorized operations for this group.
126    pub authorized_operations: i32,
127    /// Unknown tagged fields.
128    #[cfg_attr(test, proptest(strategy = "proptest_strategies::unknown_tagged_fields()"))]
129    pub _unknown_tagged_fields: Vec<RawTaggedField>,
130}
131
132impl Default for DescribedGroup {
133    fn default() -> Self {
134        DescribedGroup {
135            error_code: 0_i16,
136            error_message: None,
137            group_id: String::from(""),
138            group_state: String::from(""),
139            group_epoch: 0_i32,
140            assignment_epoch: 0_i32,
141            assignor_name: String::from(""),
142            members: Vec::<Member>::new(),
143            authorized_operations: -2147483648_i32,
144            _unknown_tagged_fields: Vec::new(),
145        }
146    }
147}
148
149impl DescribedGroup {
150    pub fn new<S1: AsRef<str>, S2: AsRef<str>, S3: AsRef<str>, S4: AsRef<str>>(error_code: i16, error_message: Option<S1>, group_id: S2, group_state: S3, group_epoch: i32, assignment_epoch: i32, assignor_name: S4, members: Vec<Member>, authorized_operations: i32) -> Self {
151        Self {
152            error_code,
153            error_message: error_message.map(|s| s.as_ref().to_string()),
154            group_id: group_id.as_ref().to_string(),
155            group_state: group_state.as_ref().to_string(),
156            group_epoch,
157            assignment_epoch,
158            assignor_name: assignor_name.as_ref().to_string(),
159            members,
160            authorized_operations,
161            _unknown_tagged_fields: vec![],
162        }
163    }
164}
165
166#[cfg(test)]
167mod tests_described_group_new_and_default {
168    use super::*;
169    
170    #[test]
171    fn test() {
172        let d = DescribedGroup::new(
173            0_i16,
174            None::<String>,
175            String::from(""),
176            String::from(""),
177            0_i32,
178            0_i32,
179            String::from(""),
180            Vec::<Member>::new(),
181            -2147483648_i32,
182        );
183        assert_eq!(d, DescribedGroup::default());
184    }
185}
186
187impl Readable for DescribedGroup {
188    fn read(#[allow(unused)] input: &mut impl Read) -> Result<Self> {
189        let error_code = i16::read(input)?;
190        let error_message = Option::<String>::read_ext(input, "error_message", true)?;
191        let group_id = String::read_ext(input, "group_id", true)?;
192        let group_state = String::read_ext(input, "group_state", true)?;
193        let group_epoch = i32::read(input)?;
194        let assignment_epoch = i32::read(input)?;
195        let assignor_name = String::read_ext(input, "assignor_name", true)?;
196        let members = read_array::<Member>(input, "members", true)?;
197        let authorized_operations = i32::read(input)?;
198        let tagged_fields_callback = |tag: i32, _: &[u8]| {
199            match tag {
200                _ => Ok(false)
201            }
202        };
203        let _unknown_tagged_fields = read_tagged_fields(input, tagged_fields_callback)?;
204        Ok(DescribedGroup {
205            error_code, error_message, group_id, group_state, group_epoch, assignment_epoch, assignor_name, members, authorized_operations, _unknown_tagged_fields
206        })
207    }
208}
209
210impl Writable for DescribedGroup {
211    fn write(&self, #[allow(unused)] output: &mut impl Write) -> Result<()> {
212        self.error_code.write(output)?;
213        self.error_message.write_ext(output, "self.error_message", true)?;
214        self.group_id.write_ext(output, "self.group_id", true)?;
215        self.group_state.write_ext(output, "self.group_state", true)?;
216        self.group_epoch.write(output)?;
217        self.assignment_epoch.write(output)?;
218        self.assignor_name.write_ext(output, "self.assignor_name", true)?;
219        write_array(output, "self.members", &self.members, true)?;
220        self.authorized_operations.write(output)?;
221        write_tagged_fields(output, &[], &self._unknown_tagged_fields)?;
222        Ok(())
223    }
224}
225
226/// Member, version 0.
227#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
228#[cfg_attr(test, derive(Arbitrary))]
229pub struct Member {
230    /// The member ID.
231    #[cfg_attr(test, proptest(strategy = "proptest_strategies::string()"))]
232    pub member_id: String,
233    /// The member rack ID.
234    #[cfg_attr(test, proptest(strategy = "proptest_strategies::optional_string()"))]
235    pub rack_id: Option<String>,
236    /// The current member epoch.
237    pub member_epoch: i32,
238    /// The client ID.
239    #[cfg_attr(test, proptest(strategy = "proptest_strategies::string()"))]
240    pub client_id: String,
241    /// The client host.
242    #[cfg_attr(test, proptest(strategy = "proptest_strategies::string()"))]
243    pub client_host: String,
244    /// The subscribed topic names.
245    #[cfg_attr(test, proptest(strategy = "proptest_strategies::vec()"))]
246    pub subscribed_topic_names: Vec<String>,
247    /// The current assignment.
248    pub assignment: Assignment,
249    /// Unknown tagged fields.
250    #[cfg_attr(test, proptest(strategy = "proptest_strategies::unknown_tagged_fields()"))]
251    pub _unknown_tagged_fields: Vec<RawTaggedField>,
252}
253
254impl Default for Member {
255    fn default() -> Self {
256        Member {
257            member_id: String::from(""),
258            rack_id: None,
259            member_epoch: 0_i32,
260            client_id: String::from(""),
261            client_host: String::from(""),
262            subscribed_topic_names: Vec::<String>::new(),
263            assignment: Assignment::default(),
264            _unknown_tagged_fields: Vec::new(),
265        }
266    }
267}
268
269impl Member {
270    pub fn new<S1: AsRef<str>, S2: AsRef<str>, S3: AsRef<str>, S4: AsRef<str>>(member_id: S1, rack_id: Option<S2>, member_epoch: i32, client_id: S3, client_host: S4, subscribed_topic_names: Vec<String>, assignment: Assignment) -> Self {
271        Self {
272            member_id: member_id.as_ref().to_string(),
273            rack_id: rack_id.map(|s| s.as_ref().to_string()),
274            member_epoch,
275            client_id: client_id.as_ref().to_string(),
276            client_host: client_host.as_ref().to_string(),
277            subscribed_topic_names,
278            assignment,
279            _unknown_tagged_fields: vec![],
280        }
281    }
282}
283
284#[cfg(test)]
285mod tests_member_new_and_default {
286    use super::*;
287    
288    #[test]
289    fn test() {
290        let d = Member::new(
291            String::from(""),
292            None::<String>,
293            0_i32,
294            String::from(""),
295            String::from(""),
296            Vec::<String>::new(),
297            Assignment::default(),
298        );
299        assert_eq!(d, Member::default());
300    }
301}
302
303impl Readable for Member {
304    fn read(#[allow(unused)] input: &mut impl Read) -> Result<Self> {
305        let member_id = String::read_ext(input, "member_id", true)?;
306        let rack_id = Option::<String>::read_ext(input, "rack_id", true)?;
307        let member_epoch = i32::read(input)?;
308        let client_id = String::read_ext(input, "client_id", true)?;
309        let client_host = String::read_ext(input, "client_host", true)?;
310        let subscribed_topic_names = read_array::<String>(input, "subscribed_topic_names", true)?;
311        let assignment = Assignment::read(input)?;
312        let tagged_fields_callback = |tag: i32, _: &[u8]| {
313            match tag {
314                _ => Ok(false)
315            }
316        };
317        let _unknown_tagged_fields = read_tagged_fields(input, tagged_fields_callback)?;
318        Ok(Member {
319            member_id, rack_id, member_epoch, client_id, client_host, subscribed_topic_names, assignment, _unknown_tagged_fields
320        })
321    }
322}
323
324impl Writable for Member {
325    fn write(&self, #[allow(unused)] output: &mut impl Write) -> Result<()> {
326        self.member_id.write_ext(output, "self.member_id", true)?;
327        self.rack_id.write_ext(output, "self.rack_id", true)?;
328        self.member_epoch.write(output)?;
329        self.client_id.write_ext(output, "self.client_id", true)?;
330        self.client_host.write_ext(output, "self.client_host", true)?;
331        write_array(output, "self.subscribed_topic_names", &self.subscribed_topic_names, true)?;
332        self.assignment.write(output)?;
333        write_tagged_fields(output, &[], &self._unknown_tagged_fields)?;
334        Ok(())
335    }
336}
337
338/// Assignment, version 0.
339#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
340#[cfg_attr(test, derive(Arbitrary))]
341pub struct Assignment {
342    /// The assigned topic-partitions to the member.
343    #[cfg_attr(test, proptest(strategy = "proptest_strategies::vec()"))]
344    pub topic_partitions: Vec<TopicPartitions>,
345    /// Unknown tagged fields.
346    #[cfg_attr(test, proptest(strategy = "proptest_strategies::unknown_tagged_fields()"))]
347    pub _unknown_tagged_fields: Vec<RawTaggedField>,
348}
349
350impl Default for Assignment {
351    fn default() -> Self {
352        Assignment {
353            topic_partitions: Vec::<TopicPartitions>::new(),
354            _unknown_tagged_fields: Vec::new(),
355        }
356    }
357}
358
359impl Assignment {
360    pub fn new(topic_partitions: Vec<TopicPartitions>) -> Self {
361        Self {
362            topic_partitions,
363            _unknown_tagged_fields: vec![],
364        }
365    }
366}
367
368#[cfg(test)]
369mod tests_assignment_new_and_default {
370    use super::*;
371    
372    #[test]
373    fn test() {
374        let d = Assignment::new(
375            Vec::<TopicPartitions>::new(),
376        );
377        assert_eq!(d, Assignment::default());
378    }
379}
380
381impl Readable for Assignment {
382    fn read(#[allow(unused)] input: &mut impl Read) -> Result<Self> {
383        let topic_partitions = read_array::<TopicPartitions>(input, "topic_partitions", true)?;
384        let tagged_fields_callback = |tag: i32, _: &[u8]| {
385            match tag {
386                _ => Ok(false)
387            }
388        };
389        let _unknown_tagged_fields = read_tagged_fields(input, tagged_fields_callback)?;
390        Ok(Assignment {
391            topic_partitions, _unknown_tagged_fields
392        })
393    }
394}
395
396impl Writable for Assignment {
397    fn write(&self, #[allow(unused)] output: &mut impl Write) -> Result<()> {
398        write_array(output, "self.topic_partitions", &self.topic_partitions, true)?;
399        write_tagged_fields(output, &[], &self._unknown_tagged_fields)?;
400        Ok(())
401    }
402}
403
404/// TopicPartitions, version 0.
405#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
406#[cfg_attr(test, derive(Arbitrary))]
407pub struct TopicPartitions {
408    /// The topic ID.
409    #[cfg_attr(test, proptest(strategy = "proptest_strategies::uuid()"))]
410    pub topic_id: Uuid,
411    /// The topic name.
412    #[cfg_attr(test, proptest(strategy = "proptest_strategies::string()"))]
413    pub topic_name: String,
414    /// The partitions.
415    #[cfg_attr(test, proptest(strategy = "proptest_strategies::vec()"))]
416    pub partitions: Vec<i32>,
417    /// Unknown tagged fields.
418    #[cfg_attr(test, proptest(strategy = "proptest_strategies::unknown_tagged_fields()"))]
419    pub _unknown_tagged_fields: Vec<RawTaggedField>,
420}
421
422impl Default for TopicPartitions {
423    fn default() -> Self {
424        TopicPartitions {
425            topic_id: Uuid::nil(),
426            topic_name: String::from(""),
427            partitions: Vec::<i32>::new(),
428            _unknown_tagged_fields: Vec::new(),
429        }
430    }
431}
432
433impl TopicPartitions {
434    pub fn new<S1: AsRef<str>>(topic_id: Uuid, topic_name: S1, partitions: Vec<i32>) -> Self {
435        Self {
436            topic_id,
437            topic_name: topic_name.as_ref().to_string(),
438            partitions,
439            _unknown_tagged_fields: vec![],
440        }
441    }
442}
443
444#[cfg(test)]
445mod tests_topic_partitions_new_and_default {
446    use super::*;
447    
448    #[test]
449    fn test() {
450        let d = TopicPartitions::new(
451            Uuid::nil(),
452            String::from(""),
453            Vec::<i32>::new(),
454        );
455        assert_eq!(d, TopicPartitions::default());
456    }
457}
458
459impl Readable for TopicPartitions {
460    fn read(#[allow(unused)] input: &mut impl Read) -> Result<Self> {
461        let topic_id = Uuid::read(input)?;
462        let topic_name = String::read_ext(input, "topic_name", true)?;
463        let partitions = read_array::<i32>(input, "partitions", true)?;
464        let tagged_fields_callback = |tag: i32, _: &[u8]| {
465            match tag {
466                _ => Ok(false)
467            }
468        };
469        let _unknown_tagged_fields = read_tagged_fields(input, tagged_fields_callback)?;
470        Ok(TopicPartitions {
471            topic_id, topic_name, partitions, _unknown_tagged_fields
472        })
473    }
474}
475
476impl Writable for TopicPartitions {
477    fn write(&self, #[allow(unused)] output: &mut impl Write) -> Result<()> {
478        self.topic_id.write(output)?;
479        self.topic_name.write_ext(output, "self.topic_name", true)?;
480        write_array(output, "self.partitions", &self.partitions, true)?;
481        write_tagged_fields(output, &[], &self._unknown_tagged_fields)?;
482        Ok(())
483    }
484}
485
486#[cfg(test)]
487mod tests {
488    use super::*;
489    use proptest::prelude::*;
490    
491    #[test]
492    fn test_java_default() {
493        crate::test_utils::test_java_default::<ShareGroupDescribeResponse>("ShareGroupDescribeResponse", 0);
494    }
495    
496    proptest! {
497        #[test]
498        fn test_serde(data: ShareGroupDescribeResponse) {
499            crate::test_utils::test_serde(&data)?;
500        }
501    }
502    
503    proptest! {
504        #[test]
505        fn test_java_arbitrary(data: ShareGroupDescribeResponse) {
506            crate::test_utils::test_java_arbitrary(&data, "ShareGroupDescribeResponse", 0);
507        }
508    }
509}