Skip to main content

kacrab_protocol/generated/
push_telemetry_response.rs

1//! Generated from PushTelemetryResponse.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 PushTelemetryResponseData {
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    pub _unknown_tagged_fields: Vec<RawTaggedField>,
23}
24impl Default for PushTelemetryResponseData {
25    fn default() -> Self {
26        Self {
27            throttle_time_ms: 0_i32,
28            error_code: 0_i16,
29            _unknown_tagged_fields: Vec::new(),
30        }
31    }
32}
33impl PushTelemetryResponseData {
34    pub fn with_throttle_time_ms(mut self, value: i32) -> Self {
35        self.throttle_time_ms = value;
36        self
37    }
38    pub fn with_error_code(mut self, value: i16) -> Self {
39        self.error_code = value;
40        self
41    }
42    pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
43        if version < 0 || version > 0 {
44            return Err(UnsupportedVersion::new(72, version).into());
45        }
46        let throttle_time_ms;
47        let error_code;
48        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
49        throttle_time_ms = read_i32(buf)?;
50        error_code = read_i16(buf)?;
51        let tagged_fields = read_tagged_fields(buf)?;
52        for field in &tagged_fields {
53            match field.tag {
54                _ => {
55                    _unknown_tagged_fields.push(field.clone());
56                },
57            }
58        }
59        Ok(Self {
60            throttle_time_ms,
61            error_code,
62            _unknown_tagged_fields,
63        })
64    }
65    pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
66        if version < 0 || version > 0 {
67            return Err(UnsupportedVersion::new(72, version).into());
68        }
69        write_i32(buf, self.throttle_time_ms);
70        write_i16(buf, self.error_code);
71        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
72        all_tags.sort_by_key(|f| f.tag);
73        write_tagged_fields(buf, &all_tags)?;
74        Ok(())
75    }
76    pub fn encoded_len(&self, version: i16) -> Result<usize> {
77        if version < 0 || version > 0 {
78            return Err(UnsupportedVersion::new(72, version).into());
79        }
80        let mut len: usize = 0;
81        len += 4;
82        len += 2;
83        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
84        all_tags.sort_by_key(|f| f.tag);
85        len += tagged_fields_len(&all_tags)?;
86        Ok(len)
87    }
88}