krabka_protocol/opt/rustwide/workdir/generated/
StreamsGroupTopologyDescriptionUpdateResponse.owned.rs1use bytes::{Buf, BufMut};
4
5use crate::{
6 Decode, Encode, ProtocolError, UnknownTaggedFields,
7 primitives::{
8 fixed::{get_i16, get_i32, put_i16, put_i32},
9 string_bytes::{
10 compact_nullable_string_len, get_compact_nullable_string_owned,
11 get_nullable_string_owned, nullable_string_len, put_compact_nullable_string,
12 put_nullable_string,
13 },
14 },
15 tagged_fields::{WriteTaggedFields, read_tagged_fields, tagged_fields_len},
16};
17pub const API_KEY: i16 = 93;
18pub const MIN_VERSION: i16 = 0;
19pub const MAX_VERSION: i16 = 0;
20pub const FLEXIBLE_MIN: i16 = 0;
21#[inline]
22#[must_use]
23pub fn is_flexible(version: i16) -> bool {
24 version >= FLEXIBLE_MIN
25}
26#[derive(Debug, Clone, PartialEq, Eq, Default)]
27pub struct StreamsGroupTopologyDescriptionUpdateResponse {
28 pub throttle_time_ms: i32,
29 pub error_code: i16,
30 pub error_message: Option<String>,
31 pub unknown_tagged_fields: UnknownTaggedFields,
32}
33impl Encode for StreamsGroupTopologyDescriptionUpdateResponse {
34 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
35 if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
36 return Err(ProtocolError::UnsupportedVersion {
37 api_key: API_KEY,
38 version,
39 });
40 }
41 let flex = is_flexible(version);
42 if version >= 0 {
43 put_i32(buf, self.throttle_time_ms);
44 }
45 if version >= 0 {
46 put_i16(buf, self.error_code);
47 }
48 if version >= 0 {
49 if flex {
50 let () = put_compact_nullable_string(buf, self.error_message.as_deref());
51 } else {
52 let () = put_nullable_string(buf, self.error_message.as_deref());
53 }
54 }
55 if flex {
56 let tagged = WriteTaggedFields::new();
57 tagged.write(buf, &self.unknown_tagged_fields);
58 }
59 Ok(())
60 }
61 fn encoded_len(&self, version: i16) -> usize {
62 let flex = is_flexible(version);
63 let mut n: usize = 0;
64 if version >= 0 {
65 n += 4;
66 }
67 if version >= 0 {
68 n += 2;
69 }
70 if version >= 0 {
71 n += if flex {
72 compact_nullable_string_len(self.error_message.as_deref())
73 } else {
74 nullable_string_len(self.error_message.as_deref())
75 };
76 }
77 if flex {
78 let known_pairs: Vec<(u32, usize)> = Vec::new();
79 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
80 }
81 n
82 }
83}
84impl Decode<'_> for StreamsGroupTopologyDescriptionUpdateResponse {
85 fn decode<B: Buf>(buf: &mut B, version: i16) -> Result<Self, ProtocolError> {
86 if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
87 return Err(ProtocolError::UnsupportedVersion {
88 api_key: API_KEY,
89 version,
90 });
91 }
92 let flex = is_flexible(version);
93 let mut out = Self::default();
94 if version >= 0 {
95 out.throttle_time_ms = get_i32(buf)?;
96 }
97 if version >= 0 {
98 out.error_code = get_i16(buf)?;
99 }
100 if version >= 0 {
101 out.error_message = if flex {
102 get_compact_nullable_string_owned(buf)?
103 } else {
104 get_nullable_string_owned(buf)?
105 };
106 }
107 if flex {
108 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
109 }
110 Ok(out)
111 }
112}
113#[cfg(test)]
114impl StreamsGroupTopologyDescriptionUpdateResponse {
115 #[must_use]
116 pub fn populated(version: i16) -> Self {
117 let mut m = Self::default();
118 if version >= 0 {
119 m.throttle_time_ms = 1i32;
120 }
121 if version >= 0 {
122 m.error_code = 1i16;
123 }
124 if version >= 0 {
125 m.error_message = Some("x".to_string());
126 }
127 m
128 }
129}
130#[must_use]
133#[allow(unused_comparisons)]
134pub fn default_json(_version: i16) -> ::serde_json::Value {
135 let mut obj = ::serde_json::Map::new();
136 obj.insert("throttleTimeMs".to_string(), ::serde_json::json!(0));
137 obj.insert("errorCode".to_string(), ::serde_json::json!(0));
138 obj.insert("errorMessage".to_string(), ::serde_json::Value::Null);
139 ::serde_json::Value::Object(obj)
140}