kafka_wire_protocol/schema/offset_delete_response/
v0.rs

1// This file was generated. Do not edit.
2
3use std::io::{Read, Result, Write};
4
5use serde::{Deserialize, Serialize};
6#[cfg(test)] use proptest_derive::Arbitrary;
7
8use crate::arrays::{read_array, write_array};
9use crate::markers::{ApiMessage, Response};
10use crate::readable_writable::{Readable, Writable};
11#[cfg(test)] use crate::test_utils::proptest_strategies;
12
13/// OffsetDeleteResponse, version 0.
14#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
15#[cfg_attr(test, derive(Arbitrary))]
16pub struct OffsetDeleteResponse {
17    /// The top-level error code, or 0 if there was no error.
18    pub error_code: i16,
19    /// The duration in milliseconds for which the request was throttled due to a quota violation, or zero if the request did not violate any quota.
20    pub throttle_time_ms: i32,
21    /// The responses for each topic.
22    #[cfg_attr(test, proptest(strategy = "proptest_strategies::vec()"))]
23    pub topics: Vec<OffsetDeleteResponseTopic>,
24}
25
26impl ApiMessage for OffsetDeleteResponse {
27    fn api_key(&self) -> i16 {
28        47
29    }
30    
31    fn version(&self) -> i16 {
32        0
33    }
34}
35
36impl Response for OffsetDeleteResponse { }
37
38impl Default for OffsetDeleteResponse {
39    fn default() -> Self {
40        OffsetDeleteResponse {
41            error_code: 0_i16,
42            throttle_time_ms: 0_i32,
43            topics: Vec::<OffsetDeleteResponseTopic>::new(),
44        }
45    }
46}
47
48impl OffsetDeleteResponse {
49    pub fn new(error_code: i16, throttle_time_ms: i32, topics: Vec<OffsetDeleteResponseTopic>) -> Self {
50        Self {
51            error_code,
52            throttle_time_ms,
53            topics,
54        }
55    }
56}
57
58#[cfg(test)]
59mod tests_offset_delete_response_new_and_default {
60    use super::*;
61    
62    #[test]
63    fn test() {
64        let d = OffsetDeleteResponse::new(
65            0_i16,
66            0_i32,
67            Vec::<OffsetDeleteResponseTopic>::new(),
68        );
69        assert_eq!(d, OffsetDeleteResponse::default());
70    }
71}
72
73impl Readable for OffsetDeleteResponse {
74    fn read(#[allow(unused)] input: &mut impl Read) -> Result<Self> {
75        let error_code = i16::read(input)?;
76        let throttle_time_ms = i32::read(input)?;
77        let topics = read_array::<OffsetDeleteResponseTopic>(input, "topics", false)?;
78        Ok(OffsetDeleteResponse {
79            error_code, throttle_time_ms, topics
80        })
81    }
82}
83
84impl Writable for OffsetDeleteResponse {
85    fn write(&self, #[allow(unused)] output: &mut impl Write) -> Result<()> {
86        self.error_code.write(output)?;
87        self.throttle_time_ms.write(output)?;
88        write_array(output, "self.topics", &self.topics, false)?;
89        Ok(())
90    }
91}
92
93/// OffsetDeleteResponseTopic, version 0.
94#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
95#[cfg_attr(test, derive(Arbitrary))]
96pub struct OffsetDeleteResponseTopic {
97    /// The topic name.
98    #[cfg_attr(test, proptest(strategy = "proptest_strategies::string()"))]
99    pub name: String,
100    /// The responses for each partition in the topic.
101    #[cfg_attr(test, proptest(strategy = "proptest_strategies::vec()"))]
102    pub partitions: Vec<OffsetDeleteResponsePartition>,
103}
104
105impl Default for OffsetDeleteResponseTopic {
106    fn default() -> Self {
107        OffsetDeleteResponseTopic {
108            name: String::from(""),
109            partitions: Vec::<OffsetDeleteResponsePartition>::new(),
110        }
111    }
112}
113
114impl OffsetDeleteResponseTopic {
115    pub fn new<S1: AsRef<str>>(name: S1, partitions: Vec<OffsetDeleteResponsePartition>) -> Self {
116        Self {
117            name: name.as_ref().to_string(),
118            partitions,
119        }
120    }
121}
122
123#[cfg(test)]
124mod tests_offset_delete_response_topic_new_and_default {
125    use super::*;
126    
127    #[test]
128    fn test() {
129        let d = OffsetDeleteResponseTopic::new(
130            String::from(""),
131            Vec::<OffsetDeleteResponsePartition>::new(),
132        );
133        assert_eq!(d, OffsetDeleteResponseTopic::default());
134    }
135}
136
137impl Readable for OffsetDeleteResponseTopic {
138    fn read(#[allow(unused)] input: &mut impl Read) -> Result<Self> {
139        let name = String::read_ext(input, "name", false)?;
140        let partitions = read_array::<OffsetDeleteResponsePartition>(input, "partitions", false)?;
141        Ok(OffsetDeleteResponseTopic {
142            name, partitions
143        })
144    }
145}
146
147impl Writable for OffsetDeleteResponseTopic {
148    fn write(&self, #[allow(unused)] output: &mut impl Write) -> Result<()> {
149        self.name.write_ext(output, "self.name", false)?;
150        write_array(output, "self.partitions", &self.partitions, false)?;
151        Ok(())
152    }
153}
154
155/// OffsetDeleteResponsePartition, version 0.
156#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
157#[cfg_attr(test, derive(Arbitrary))]
158pub struct OffsetDeleteResponsePartition {
159    /// The partition index.
160    pub partition_index: i32,
161    /// The error code, or 0 if there was no error.
162    pub error_code: i16,
163}
164
165impl Default for OffsetDeleteResponsePartition {
166    fn default() -> Self {
167        OffsetDeleteResponsePartition {
168            partition_index: 0_i32,
169            error_code: 0_i16,
170        }
171    }
172}
173
174impl OffsetDeleteResponsePartition {
175    pub fn new(partition_index: i32, error_code: i16) -> Self {
176        Self {
177            partition_index,
178            error_code,
179        }
180    }
181}
182
183#[cfg(test)]
184mod tests_offset_delete_response_partition_new_and_default {
185    use super::*;
186    
187    #[test]
188    fn test() {
189        let d = OffsetDeleteResponsePartition::new(
190            0_i32,
191            0_i16,
192        );
193        assert_eq!(d, OffsetDeleteResponsePartition::default());
194    }
195}
196
197impl Readable for OffsetDeleteResponsePartition {
198    fn read(#[allow(unused)] input: &mut impl Read) -> Result<Self> {
199        let partition_index = i32::read(input)?;
200        let error_code = i16::read(input)?;
201        Ok(OffsetDeleteResponsePartition {
202            partition_index, error_code
203        })
204    }
205}
206
207impl Writable for OffsetDeleteResponsePartition {
208    fn write(&self, #[allow(unused)] output: &mut impl Write) -> Result<()> {
209        self.partition_index.write(output)?;
210        self.error_code.write(output)?;
211        Ok(())
212    }
213}
214
215#[cfg(test)]
216mod tests {
217    use super::*;
218    use proptest::prelude::*;
219    
220    #[test]
221    fn test_java_default() {
222        crate::test_utils::test_java_default::<OffsetDeleteResponse>("OffsetDeleteResponse", 0);
223    }
224    
225    proptest! {
226        #[test]
227        fn test_serde(data: OffsetDeleteResponse) {
228            crate::test_utils::test_serde(&data)?;
229        }
230    }
231    
232    proptest! {
233        #[test]
234        fn test_java_arbitrary(data: OffsetDeleteResponse) {
235            crate::test_utils::test_java_arbitrary(&data, "OffsetDeleteResponse", 0);
236        }
237    }
238}