kacrab_protocol/generated/
response_header.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 ResponseHeaderData {
17 pub correlation_id: i32,
19 pub _unknown_tagged_fields: Vec<RawTaggedField>,
20}
21impl Default for ResponseHeaderData {
22 fn default() -> Self {
23 Self {
24 correlation_id: 0_i32,
25 _unknown_tagged_fields: Vec::new(),
26 }
27 }
28}
29impl ResponseHeaderData {
30 pub fn with_correlation_id(mut self, value: i32) -> Self {
31 self.correlation_id = value;
32 self
33 }
34 pub fn read(buf: &mut Bytes, version: i16) -> Result<Self> {
35 let correlation_id;
36 let mut _unknown_tagged_fields: Vec<RawTaggedField> = Vec::new();
37 correlation_id = read_i32(buf)?;
38 if version >= 1 {
39 let tagged_fields = read_tagged_fields(buf)?;
40 for field in &tagged_fields {
41 match field.tag {
42 _ => {
43 _unknown_tagged_fields.push(field.clone());
44 },
45 }
46 }
47 }
48 Ok(Self {
49 correlation_id,
50 _unknown_tagged_fields,
51 })
52 }
53 pub fn write(&self, buf: &mut BytesMut, version: i16) -> Result<()> {
54 write_i32(buf, self.correlation_id);
55 if version >= 1 {
56 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
57 all_tags.sort_by_key(|f| f.tag);
58 write_tagged_fields(buf, &all_tags)?;
59 }
60 Ok(())
61 }
62 pub fn encoded_len(&self, version: i16) -> Result<usize> {
63 let mut len: usize = 0;
64 len += 4;
65 if version >= 1 {
66 let mut all_tags: Vec<RawTaggedField> = self._unknown_tagged_fields.clone();
67 all_tags.sort_by_key(|f| f.tag);
68 len += tagged_fields_len(&all_tags)?;
69 }
70 Ok(len)
71 }
72}