Skip to main content

kacrab_protocol/generated/
get_telemetry_subscriptions_response.rs

1//! Generated from GetTelemetrySubscriptionsResponse.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 GetTelemetrySubscriptionsResponseData {
17    /// The duration in milliseconds for which the request was throttled due to a quota violation,
18    /// or zero if the request did not violate any quota.
19    pub throttle_time_ms: i32,
20    /// The error code, or 0 if there was no error.
21    pub error_code: i16,
22    /// Assigned client instance id if ClientInstanceId was 0 in the request, else 0.
23    pub client_instance_id: KafkaUuid,
24    /// Unique identifier for the current subscription set for this client instance.
25    pub subscription_id: i32,
26    /// Compression types that broker accepts for the PushTelemetryRequest.
27    pub accepted_compression_types: Vec<i8>,
28    /// Configured push interval, which is the lowest configured interval in the current
29    /// subscription set.
30    pub push_interval_ms: i32,
31    /// The maximum bytes of binary data the broker accepts in PushTelemetryRequest.
32    pub telemetry_max_bytes: i32,
33    /// Flag to indicate monotonic/counter metrics are to be emitted as deltas or cumulative
34    /// values.
35    pub delta_temporality: bool,
36    /// Requested metrics prefix string match. Empty array: No metrics subscribed, Array\[0\] empty
37    /// string: All metrics subscribed.
38    pub requested_metrics: Vec<KafkaString>,
39    pub _unknown_tagged_fields: Vec<RawTaggedField>,
40}
41impl Default for GetTelemetrySubscriptionsResponseData {
42    fn default() -> Self {
43        Self {
44            throttle_time_ms: 0_i32,
45            error_code: 0_i16,
46            client_instance_id: KafkaUuid::ZERO,
47            subscription_id: 0_i32,
48            accepted_compression_types: Vec::new(),
49            push_interval_ms: 0_i32,
50            telemetry_max_bytes: 0_i32,
51            delta_temporality: false,
52            requested_metrics: Vec::new(),
53            _unknown_tagged_fields: Vec::new(),
54        }
55    }
56}
57impl GetTelemetrySubscriptionsResponseData {
58    pub fn with_throttle_time_ms(mut self, value: i32) -> Self {
59        self.throttle_time_ms = value;
60        self
61    }
62    pub fn with_error_code(mut self, value: i16) -> Self {
63        self.error_code = value;
64        self
65    }
66    pub fn with_client_instance_id(mut self, value: KafkaUuid) -> Self {
67        self.client_instance_id = value;
68        self
69    }
70    pub fn with_subscription_id(mut self, value: i32) -> Self {
71        self.subscription_id = value;
72        self
73    }
74    pub fn with_accepted_compression_types(mut self, value: Vec<i8>) -> Self {
75        self.accepted_compression_types = value;
76        self
77    }
78    pub fn with_push_interval_ms(mut self, value: i32) -> Self {
79        self.push_interval_ms = value;
80        self
81    }
82    pub fn with_telemetry_max_bytes(mut self, value: i32) -> Self {
83        self.telemetry_max_bytes = value;
84        self
85    }
86    pub fn with_delta_temporality(mut self, value: bool) -> Self {
87        self.delta_temporality = value;
88        self
89    }
90    pub fn with_requested_metrics(mut self, value: Vec<KafkaString>) -> Self {
91        self.requested_metrics = value;
92        self
93    }
94    pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
95        if version < 0 || version > 0 {
96            return Err(UnsupportedVersion::new(71, version).into());
97        }
98        let throttle_time_ms;
99        let error_code;
100        let client_instance_id;
101        let subscription_id;
102        let accepted_compression_types;
103        let push_interval_ms;
104        let telemetry_max_bytes;
105        let delta_temporality;
106        let requested_metrics;
107        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
108        throttle_time_ms = read_i32(buf)?;
109        error_code = read_i16(buf)?;
110        client_instance_id = read_uuid(buf)?;
111        subscription_id = read_i32(buf)?;
112        accepted_compression_types = {
113            let len = read_compact_array_length(buf)?;
114            let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
115            for _ in 0..len {
116                arr.push(read_i8(buf)?);
117            }
118            arr
119        };
120        push_interval_ms = read_i32(buf)?;
121        telemetry_max_bytes = read_i32(buf)?;
122        delta_temporality = read_bool(buf)?;
123        requested_metrics = {
124            let len = read_compact_array_length(buf)?;
125            let mut arr = Vec::with_capacity(array_read_capacity(len, (buf).len()));
126            for _ in 0..len {
127                arr.push(read_compact_string(buf)?);
128            }
129            arr
130        };
131        let tagged_fields = read_tagged_fields(buf)?;
132        for field in &tagged_fields {
133            match field.tag {
134                _ => {
135                    _unknown_tagged_fields.push(field.clone());
136                },
137            }
138        }
139        Ok(Self {
140            throttle_time_ms,
141            error_code,
142            client_instance_id,
143            subscription_id,
144            accepted_compression_types,
145            push_interval_ms,
146            telemetry_max_bytes,
147            delta_temporality,
148            requested_metrics,
149            _unknown_tagged_fields,
150        })
151    }
152    pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
153        if version < 0 || version > 0 {
154            return Err(UnsupportedVersion::new(71, version).into());
155        }
156        write_i32(buf, self.throttle_time_ms);
157        write_i16(buf, self.error_code);
158        write_uuid(buf, &self.client_instance_id);
159        write_i32(buf, self.subscription_id);
160        write_compact_array_length(buf, self.accepted_compression_types.len() as i32);
161        for el in &self.accepted_compression_types {
162            write_i8(buf, *el);
163        }
164        write_i32(buf, self.push_interval_ms);
165        write_i32(buf, self.telemetry_max_bytes);
166        write_bool(buf, self.delta_temporality);
167        write_compact_array_length(buf, self.requested_metrics.len() as i32);
168        for el in &self.requested_metrics {
169            write_compact_string(buf, el)?;
170        }
171        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
172        all_tags.sort_by_key(|f| f.tag);
173        write_tagged_fields(buf, &all_tags)?;
174        Ok(())
175    }
176    pub fn encoded_len(&self, version: i16) -> Result<usize> {
177        if version < 0 || version > 0 {
178            return Err(UnsupportedVersion::new(71, version).into());
179        }
180        let mut len: usize = 0;
181        len += 4;
182        len += 2;
183        len += 16;
184        len += 4;
185        len += compact_array_length_len(self.accepted_compression_types.len() as i32);
186        len += self.accepted_compression_types.len() * 1usize;
187        len += 4;
188        len += 4;
189        len += 1;
190        len += compact_array_length_len(self.requested_metrics.len() as i32);
191        for el in &self.requested_metrics {
192            len += compact_string_len(el)?;
193        }
194        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
195        all_tags.sort_by_key(|f| f.tag);
196        len += tagged_fields_len(&all_tags)?;
197        Ok(len)
198    }
199}