Skip to main content

crabka_protocol/opt/rustwide/workdir/generated/
DeleteShareGroupOffsetsResponse.owned.rs

1// AUTO-GENERATED by crabka-protocol-codegen against a9ce3221537b8653448750697915607dc7936cf3. Do not edit.
2
3use bytes::{Buf, BufMut};
4
5use crate::primitives::fixed::{get_i16, get_i32, put_i16, put_i32};
6use crate::primitives::string_bytes::{
7    compact_nullable_string_len, compact_string_len, get_compact_nullable_string_owned,
8    get_compact_string_owned, get_nullable_string_owned, get_string_owned, nullable_string_len,
9    put_compact_nullable_string, put_compact_string, put_nullable_string, put_string,
10    string_len,
11};
12use crate::tagged_fields::{read_tagged_fields, tagged_fields_len, WriteTaggedFields};
13use crate::{Decode, Encode, ProtocolError, UnknownTaggedFields};
14
15pub const API_KEY: i16 = 92;
16pub const MIN_VERSION: i16 = 0;
17pub const MAX_VERSION: i16 = 0;
18pub const FLEXIBLE_MIN: i16 = 0;
19
20#[inline]
21fn is_flexible(version: i16) -> bool { version >= FLEXIBLE_MIN }
22
23#[derive(Debug, Clone, PartialEq, Eq, Default)]
24pub struct DeleteShareGroupOffsetsResponse {
25    pub throttle_time_ms: i32,
26    pub error_code: i16,
27    pub error_message: Option<String>,
28    pub responses: Vec<DeleteShareGroupOffsetsResponseTopic>,
29    pub unknown_tagged_fields: UnknownTaggedFields,
30}
31
32impl Encode for DeleteShareGroupOffsetsResponse {
33    fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
34        if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
35            return Err(ProtocolError::UnsupportedVersion { api_key: API_KEY, version });
36        }
37        let flex = is_flexible(version);
38        if version >= 0 { put_i32(buf, self.throttle_time_ms) }
39        if version >= 0 { put_i16(buf, self.error_code) }
40        if version >= 0 { if flex { put_compact_nullable_string(buf, self.error_message.as_deref()) } else { put_nullable_string(buf, self.error_message.as_deref()) } }
41        if version >= 0 { { crate::primitives::array::put_array_len(buf, (self.responses).len(), flex); for it in &self.responses { it.encode(buf, version)?; } } }
42        if flex {
43            let tagged = WriteTaggedFields::new();
44            tagged.write(buf, &self.unknown_tagged_fields);
45        }
46        Ok(())
47    }
48    fn encoded_len(&self, version: i16) -> usize {
49        let flex = is_flexible(version);
50        let mut n: usize = 0;
51        if version >= 0 { n += 4; }
52        if version >= 0 { n += 2; }
53        if version >= 0 { n += if flex { compact_nullable_string_len(self.error_message.as_deref()) } else { nullable_string_len(self.error_message.as_deref()) }; }
54        if version >= 0 { n += { let prefix = crate::primitives::array::array_len_prefix_len((self.responses).len(), flex); let body: usize = (self.responses).iter().map(|it| it.encoded_len(version)).sum(); prefix + body }; }
55        if flex {
56            let known_pairs: Vec<(u32, usize)> = Vec::new();
57            n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
58        }
59        n
60    }
61}
62
63impl<'de> Decode<'de> for DeleteShareGroupOffsetsResponse {
64    fn decode<B: Buf>(buf: &mut B, version: i16) -> Result<Self, ProtocolError> {
65        if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
66            return Err(ProtocolError::UnsupportedVersion { api_key: API_KEY, version });
67        }
68        let flex = is_flexible(version);
69        let mut out = Self::default();
70        if version >= 0 { out.throttle_time_ms = get_i32(buf)?; }
71        if version >= 0 { out.error_code = get_i16(buf)?; }
72        if version >= 0 { out.error_message = if flex { get_compact_nullable_string_owned(buf)? } else { get_nullable_string_owned(buf)? }; }
73        if version >= 0 { out.responses = { let n = crate::primitives::array::get_array_len(buf, flex)?; let mut v = Vec::with_capacity(n); for _ in 0..n { v.push(DeleteShareGroupOffsetsResponseTopic::decode(buf, version)?); } v }; }
74        if flex {
75            out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| {
76                Ok(false)
77            })?;
78        }
79        Ok(out)
80    }
81}
82
83#[derive(Debug, Clone, PartialEq, Eq, Default)]
84pub struct DeleteShareGroupOffsetsResponseTopic {
85    pub topic_name: String,
86    pub topic_id: crate::primitives::uuid::Uuid,
87    pub error_code: i16,
88    pub error_message: Option<String>,
89    pub unknown_tagged_fields: UnknownTaggedFields,
90}
91
92impl Encode for DeleteShareGroupOffsetsResponseTopic {
93    fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
94        let flex = version >= 0;
95        if version >= 0 { if flex { put_compact_string(buf, &self.topic_name) } else { put_string(buf, &self.topic_name) } }
96        if version >= 0 { crate::primitives::uuid::put_uuid(buf, self.topic_id) }
97        if version >= 0 { put_i16(buf, self.error_code) }
98        if version >= 0 { if flex { put_compact_nullable_string(buf, self.error_message.as_deref()) } else { put_nullable_string(buf, self.error_message.as_deref()) } }
99        if flex {
100            let tagged = WriteTaggedFields::new();
101            tagged.write(buf, &self.unknown_tagged_fields);
102        }
103        Ok(())
104    }
105    fn encoded_len(&self, version: i16) -> usize {
106        let flex = version >= 0;
107        let mut n: usize = 0;
108        if version >= 0 { n += if flex { compact_string_len(&self.topic_name) } else { string_len(&self.topic_name) }; }
109        if version >= 0 { n += 16; }
110        if version >= 0 { n += 2; }
111        if version >= 0 { n += if flex { compact_nullable_string_len(self.error_message.as_deref()) } else { nullable_string_len(self.error_message.as_deref()) }; }
112        if flex {
113            let known_pairs: Vec<(u32, usize)> = Vec::new();
114            n += tagged_fields_len(&known_pairs, &self.unknown_tagged_fields);
115        }
116        n
117    }
118}
119
120impl<'de> Decode<'de> for DeleteShareGroupOffsetsResponseTopic {
121    fn decode<B: Buf>(buf: &mut B, version: i16) -> Result<Self, ProtocolError> {
122        let flex = version >= 0;
123        let mut out = Self::default();
124        if version >= 0 { out.topic_name = if flex { get_compact_string_owned(buf)? } else { get_string_owned(buf)? }; }
125        if version >= 0 { out.topic_id = crate::primitives::uuid::get_uuid(buf)?; }
126        if version >= 0 { out.error_code = get_i16(buf)?; }
127        if version >= 0 { out.error_message = if flex { get_compact_nullable_string_owned(buf)? } else { get_nullable_string_owned(buf)? }; }
128        if flex {
129            out.unknown_tagged_fields = read_tagged_fields(buf, |_tag, _payload| {
130                Ok(false)
131            })?;
132        }
133        Ok(out)
134    }
135}
136
137/// Default JSON payload matching `Self::default()` for JVM oracle differential testing.
138/// Only includes fields valid for the given version.
139#[must_use]
140#[allow(unused_comparisons)]
141pub fn default_json(version: i16) -> ::serde_json::Value {
142    let mut obj = ::serde_json::Map::new();
143    obj.insert("throttleTimeMs".to_string(), ::serde_json::json!(0));
144    obj.insert("errorCode".to_string(), ::serde_json::json!(0));
145    obj.insert("errorMessage".to_string(), ::serde_json::Value::Null);
146    obj.insert("responses".to_string(), ::serde_json::Value::Array(vec![]));
147    ::serde_json::Value::Object(obj)
148}