Skip to main content

kacrab_protocol/generated/
consumer_group_describe_request.rs

1//! Generated from ConsumerGroupDescribeRequest.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 ConsumerGroupDescribeRequestData {
17    /// The ids of the groups to describe.
18    pub group_ids: Vec<KafkaString>,
19    /// Whether to include authorized operations.
20    pub include_authorized_operations: bool,
21    pub _unknown_tagged_fields: Vec<RawTaggedField>,
22}
23impl Default for ConsumerGroupDescribeRequestData {
24    fn default() -> Self {
25        Self {
26            group_ids: Vec::new(),
27            include_authorized_operations: false,
28            _unknown_tagged_fields: Vec::new(),
29        }
30    }
31}
32impl ConsumerGroupDescribeRequestData {
33    pub fn with_group_ids(mut self, value: Vec<KafkaString>) -> Self {
34        self.group_ids = value;
35        self
36    }
37    pub fn with_include_authorized_operations(mut self, value: bool) -> Self {
38        self.include_authorized_operations = value;
39        self
40    }
41    pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
42        if version < 0 || version > 1 {
43            return Err(UnsupportedVersion::new(69, version).into());
44        }
45        let group_ids;
46        let include_authorized_operations;
47        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
48        group_ids = {
49            let len = read_compact_array_length(buf)?;
50            let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
51            for _ in 0..len {
52                arr.push(read_compact_string(buf)?);
53            }
54            arr
55        };
56        include_authorized_operations = read_bool(buf)?;
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_ids,
67            include_authorized_operations,
68            _unknown_tagged_fields,
69        })
70    }
71    pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
72        if version < 0 || version > 1 {
73            return Err(UnsupportedVersion::new(69, version).into());
74        }
75        write_compact_array_length(buf, self.group_ids.len() as i32);
76        for el in &self.group_ids {
77            write_compact_string(buf, el)?;
78        }
79        write_bool(buf, self.include_authorized_operations);
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 > 1 {
87            return Err(UnsupportedVersion::new(69, version).into());
88        }
89        let mut len: usize = 0;
90        len += compact_array_length_len(self.group_ids.len() as i32);
91        for el in &self.group_ids {
92            len += compact_string_len(el)?;
93        }
94        len += 1;
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}