krabka_protocol/opt/rustwide/workdir/generated/
StreamsGroupTopologyDescriptionUpdateRequest.borrowed.rs1use bytes::BufMut;
3
4use crate::{
5 DecodeBorrow, Encode, ProtocolError, UnknownTaggedFields,
6 primitives::{
7 fixed::{get_i32, put_i32},
8 string_bytes::{compact_string_len, put_compact_string, put_string, string_len},
9 string_bytes_borrowed::{get_compact_string_borrowed, get_string_borrowed},
10 },
11 tagged_fields::{WriteTaggedFields, read_tagged_fields, tagged_fields_len},
12};
13pub const API_KEY: i16 = 93;
14pub const MIN_VERSION: i16 = 0;
15pub const MAX_VERSION: i16 = 0;
16pub const LATEST_STABLE_VERSION: i16 = 0;
17pub const FLEXIBLE_MIN: i16 = 0;
18#[inline]
19#[must_use]
20pub fn is_flexible(version: i16) -> bool {
21 version >= FLEXIBLE_MIN
22}
23#[derive(Debug, Clone, PartialEq, Eq, Default)]
24pub struct StreamsGroupTopologyDescriptionUpdateRequest<'a> {
25 pub group_id: &'a str,
26 pub member_id: &'a str,
27 pub topology_epoch: i32,
28 pub topology_description: super::common::streams_group_topology_description_update_request::topology_description::TopologyDescription<'a>,
29 pub unknown_tagged_fields: UnknownTaggedFields,
30}
31impl StreamsGroupTopologyDescriptionUpdateRequest<'_> {
32 #[must_use]
36 pub fn to_owned(&self) -> crate::owned::streams_group_topology_description_update_request::StreamsGroupTopologyDescriptionUpdateRequest{
37 crate::owned::streams_group_topology_description_update_request::StreamsGroupTopologyDescriptionUpdateRequest {
38 group_id: (self.group_id).to_string(),
39 member_id: (self.member_id).to_string(),
40 topology_epoch: (self.topology_epoch),
41 topology_description: (self.topology_description).to_owned(),
42 unknown_tagged_fields: self.unknown_tagged_fields.clone(),
43 }
44 }
45}
46impl Encode for StreamsGroupTopologyDescriptionUpdateRequest<'_> {
47 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
48 if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
49 return Err(ProtocolError::UnsupportedVersion {
50 api_key: API_KEY,
51 version,
52 });
53 }
54 let flex = is_flexible(version);
55 if version >= 0 {
56 if flex {
57 let () = put_compact_string(buf, self.group_id);
58 } else {
59 let () = put_string(buf, self.group_id);
60 }
61 }
62 if version >= 0 {
63 if flex {
64 let () = put_compact_string(buf, self.member_id);
65 } else {
66 let () = put_string(buf, self.member_id);
67 }
68 }
69 if version >= 0 {
70 put_i32(buf, self.topology_epoch);
71 }
72 if version >= 0 {
73 self.topology_description.encode(buf, version)?;
74 }
75 if flex {
76 let tagged = WriteTaggedFields::new();
77 tagged.write(buf, &self.unknown_tagged_fields);
78 }
79 Ok(())
80 }
81 fn encoded_len(&self, version: i16) -> usize {
82 let flex = is_flexible(version);
83 let mut n: usize = 0;
84 if version >= 0 {
85 n += if flex {
86 compact_string_len(self.group_id)
87 } else {
88 string_len(self.group_id)
89 };
90 }
91 if version >= 0 {
92 n += if flex {
93 compact_string_len(self.member_id)
94 } else {
95 string_len(self.member_id)
96 };
97 }
98 if version >= 0 {
99 n += 4;
100 }
101 if version >= 0 {
102 n += self.topology_description.encoded_len(version);
103 }
104 if flex {
105 let known_pairs: Vec<(u32, usize)> = Vec::new();
106 n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
107 }
108 n
109 }
110}
111impl<'de> DecodeBorrow<'de> for StreamsGroupTopologyDescriptionUpdateRequest<'de> {
112 fn decode_borrow(buf: &mut &'de [u8], version: i16) -> Result<Self, ProtocolError> {
113 if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
114 return Err(ProtocolError::UnsupportedVersion {
115 api_key: API_KEY,
116 version,
117 });
118 }
119 let flex = is_flexible(version);
120 let mut out = Self::default();
121 if version >= 0 {
122 out.group_id = if flex {
123 get_compact_string_borrowed(buf)?
124 } else {
125 get_string_borrowed(buf)?
126 };
127 }
128 if version >= 0 {
129 out.member_id = if flex {
130 get_compact_string_borrowed(buf)?
131 } else {
132 get_string_borrowed(buf)?
133 };
134 }
135 if version >= 0 {
136 out.topology_epoch = get_i32(buf)?;
137 }
138 if version >= 0 {
139 out.topology_description = super::common::streams_group_topology_description_update_request::topology_description::TopologyDescription::decode_borrow(buf, version)?;
140 }
141 if flex {
142 out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| Ok(false))?;
143 }
144 Ok(out)
145 }
146}
147#[cfg(test)]
148impl StreamsGroupTopologyDescriptionUpdateRequest<'_> {
149 #[must_use]
150 pub fn populated(version: i16) -> Self {
151 let mut m = Self::default();
152 if version >= 0 {
153 m.group_id = "x";
154 }
155 if version >= 0 {
156 m.member_id = "x";
157 }
158 if version >= 0 {
159 m.topology_epoch = 1i32;
160 }
161 if version >= 0 {
162 m.topology_description = super::common::streams_group_topology_description_update_request::topology_description::TopologyDescription::populated(version);
163 }
164 m
165 }
166}