kacrab_protocol/generated/
push_telemetry_request.rs1#![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 PushTelemetryRequestData {
17 pub client_instance_id: KafkaUuid,
19 pub subscription_id: i32,
21 pub terminating: bool,
23 pub compression_type: i8,
25 pub metrics: Bytes,
27 pub _unknown_tagged_fields: Vec<RawTaggedField>,
28}
29impl Default for PushTelemetryRequestData {
30 fn default() -> Self {
31 Self {
32 client_instance_id: KafkaUuid::ZERO,
33 subscription_id: 0_i32,
34 terminating: false,
35 compression_type: 0_i8,
36 metrics: Bytes::new(),
37 _unknown_tagged_fields: Vec::new(),
38 }
39 }
40}
41impl PushTelemetryRequestData {
42 pub fn with_client_instance_id(mut self, value: KafkaUuid) -> Self {
43 self.client_instance_id = value;
44 self
45 }
46 pub fn with_subscription_id(mut self, value: i32) -> Self {
47 self.subscription_id = value;
48 self
49 }
50 pub fn with_terminating(mut self, value: bool) -> Self {
51 self.terminating = value;
52 self
53 }
54 pub fn with_compression_type(mut self, value: i8) -> Self {
55 self.compression_type = value;
56 self
57 }
58 pub fn with_metrics(mut self, value: Bytes) -> Self {
59 self.metrics = value;
60 self
61 }
62 pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
63 if version < 0 || version > 0 {
64 return Err(UnsupportedVersion::new(72, version).into());
65 }
66 let client_instance_id;
67 let subscription_id;
68 let terminating;
69 let compression_type;
70 let metrics;
71 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
72 client_instance_id = read_uuid(buf)?;
73 subscription_id = read_i32(buf)?;
74 terminating = read_bool(buf)?;
75 compression_type = read_i8(buf)?;
76 metrics = read_compact_bytes(buf)?;
77 let tagged_fields = read_tagged_fields(buf)?;
78 for field in &tagged_fields {
79 match field.tag {
80 _ => {
81 _unknown_tagged_fields.push(field.clone());
82 },
83 }
84 }
85 Ok(Self {
86 client_instance_id,
87 subscription_id,
88 terminating,
89 compression_type,
90 metrics,
91 _unknown_tagged_fields,
92 })
93 }
94 pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
95 if version < 0 || version > 0 {
96 return Err(UnsupportedVersion::new(72, version).into());
97 }
98 write_uuid(buf, &self.client_instance_id);
99 write_i32(buf, self.subscription_id);
100 write_bool(buf, self.terminating);
101 write_i8(buf, self.compression_type);
102 write_compact_bytes(buf, &self.metrics)?;
103 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
104 all_tags.sort_by_key(|f| f.tag);
105 write_tagged_fields(buf, &all_tags)?;
106 Ok(())
107 }
108 pub fn encoded_len(&self, version: i16) -> Result<usize> {
109 if version < 0 || version > 0 {
110 return Err(UnsupportedVersion::new(72, version).into());
111 }
112 let mut len: usize = 0;
113 len += 16;
114 len += 4;
115 len += 1;
116 len += 1;
117 len += compact_bytes_len(&self.metrics)?;
118 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
119 all_tags.sort_by_key(|f| f.tag);
120 len += tagged_fields_len(&all_tags)?;
121 Ok(len)
122 }
123}