Skip to main content

kacrab_protocol/generated/
get_telemetry_subscriptions_request.rs

1//! Generated from GetTelemetrySubscriptionsRequest.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 GetTelemetrySubscriptionsRequestData {
17    /// Unique id for this client instance, must be set to 0 on the first request.
18    pub client_instance_id: KafkaUuid,
19    pub _unknown_tagged_fields: Vec<RawTaggedField>,
20}
21impl Default for GetTelemetrySubscriptionsRequestData {
22    fn default() -> Self {
23        Self {
24            client_instance_id: KafkaUuid::ZERO,
25            _unknown_tagged_fields: Vec::new(),
26        }
27    }
28}
29impl GetTelemetrySubscriptionsRequestData {
30    pub fn with_client_instance_id(mut self, value: KafkaUuid) -> Self {
31        self.client_instance_id = value;
32        self
33    }
34    pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
35        if version < 0 || version > 0 {
36            return Err(UnsupportedVersion::new(71, version).into());
37        }
38        let client_instance_id;
39        let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
40        client_instance_id = read_uuid(buf)?;
41        let tagged_fields = read_tagged_fields(buf)?;
42        for field in &tagged_fields {
43            match field.tag {
44                _ => {
45                    _unknown_tagged_fields.push(field.clone());
46                },
47            }
48        }
49        Ok(Self {
50            client_instance_id,
51            _unknown_tagged_fields,
52        })
53    }
54    pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
55        if version < 0 || version > 0 {
56            return Err(UnsupportedVersion::new(71, version).into());
57        }
58        write_uuid(buf, &self.client_instance_id);
59        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
60        all_tags.sort_by_key(|f| f.tag);
61        write_tagged_fields(buf, &all_tags)?;
62        Ok(())
63    }
64    pub fn encoded_len(&self, version: i16) -> Result<usize> {
65        if version < 0 || version > 0 {
66            return Err(UnsupportedVersion::new(71, version).into());
67        }
68        let mut len: usize = 0;
69        len += 16;
70        let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
71        all_tags.sort_by_key(|f| f.tag);
72        len += tagged_fields_len(&all_tags)?;
73        Ok(len)
74    }
75}