crabka_protocol/opt/rustwide/workdir/generated/
StreamsGroupDescribeRequest.owned.rs1use bytes::{Buf, BufMut};
4
5use crate::primitives::fixed::{get_bool, put_bool};
6use crate::primitives::string_bytes::{
7 compact_string_len, get_compact_string_owned, get_string_owned,
8 put_compact_string, put_string, string_len,
9};
10use crate::tagged_fields::{read_tagged_fields, tagged_fields_len, WriteTaggedFields};
11use crate::{Decode, Encode, ProtocolError, UnknownTaggedFields};
12
13pub const API_KEY: i16 = 89;
14pub const MIN_VERSION: i16 = 0;
15pub const MAX_VERSION: i16 = 0;
16pub const FLEXIBLE_MIN: i16 = 0;
17
18#[inline]
19fn is_flexible(version: i16) -> bool { version >= FLEXIBLE_MIN }
20
21#[derive(Debug, Clone, PartialEq, Eq, Default)]
22pub struct StreamsGroupDescribeRequest {
23 pub group_ids: Vec<String>,
24 pub include_authorized_operations: bool,
25 pub unknown_tagged_fields: UnknownTaggedFields,
26}
27
28impl Encode for StreamsGroupDescribeRequest {
29 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
30 if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
31 return Err(ProtocolError::UnsupportedVersion { api_key: API_KEY, version });
32 }
33 let flex = is_flexible(version);
34 if version >= 0 { { crate::primitives::array::put_array_len(buf, (self.group_ids).len(), flex); for it in &self.group_ids { if flex { put_compact_string(buf, &*it) } else { put_string(buf, &*it) }; } } }
35 if version >= 0 { put_bool(buf, self.include_authorized_operations) }
36 if flex {
37 let tagged = WriteTaggedFields::new();
38 tagged.write(buf, &self.unknown_tagged_fields);
39 }
40 Ok(())
41 }
42 fn encoded_len(&self, version: i16) -> usize {
43 let flex = is_flexible(version);
44 let mut n: usize = 0;
45 if version >= 0 { n += { let prefix = crate::primitives::array::array_len_prefix_len((self.group_ids).len(), flex); let body: usize = (self.group_ids).iter().map(|it| if flex { compact_string_len(&*it) } else { string_len(&*it) }).sum(); prefix + body }; }
46 if version >= 0 { n += 1; }
47 if flex {
48 let known_pairs: Vec<(u32, usize)> = Vec::new();
49 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
50 }
51 n
52 }
53}
54
55impl<'de> Decode<'de> for StreamsGroupDescribeRequest {
56 fn decode<B: Buf>(buf: &mut B, version: i16) -> Result<Self, ProtocolError> {
57 if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
58 return Err(ProtocolError::UnsupportedVersion { api_key: API_KEY, version });
59 }
60 let flex = is_flexible(version);
61 let mut out = Self::default();
62 if version >= 0 { out.group_ids = { 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 }; }
63 if version >= 0 { out.include_authorized_operations = get_bool(buf)?; }
64 if flex {
65 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| {
66 Ok(false)
67 })?;
68 }
69 Ok(out)
70 }
71}
72
73#[must_use]
76#[allow(unused_comparisons)]
77pub fn default_json(version: i16) -> ::serde_json::Value {
78 let mut obj = ::serde_json::Map::new();
79 obj.insert("groupIds".to_string(), ::serde_json::Value::Array(vec![]));
80 obj.insert("includeAuthorizedOperations".to_string(), ::serde_json::Value::Bool(false));
81 ::serde_json::Value::Object(obj)
82}
83
84impl crate::ProtocolRequest for StreamsGroupDescribeRequest {
85 const API_KEY: i16 = API_KEY;
86 const MIN_VERSION: i16 = MIN_VERSION;
87 const MAX_VERSION: i16 = MAX_VERSION;
88 const FLEXIBLE_MIN: i16 = FLEXIBLE_MIN;
89 type Response = super::streams_group_describe_response::StreamsGroupDescribeResponse;
90}