kafka_wire_protocol/schema/describe_log_dirs_response/
v3.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};
11use crate::tagged_fields::{RawTaggedField, read_tagged_fields, write_tagged_fields};
12#[cfg(test)] use crate::test_utils::proptest_strategies;
13
14/// DescribeLogDirsResponse, version 3.
15#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
16#[cfg_attr(test, derive(Arbitrary))]
17pub struct DescribeLogDirsResponse {
18    /// 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.
19    pub throttle_time_ms: i32,
20    /// The error code, or 0 if there was no error.
21    pub error_code: i16,
22    /// The log directories.
23    #[cfg_attr(test, proptest(strategy = "proptest_strategies::vec()"))]
24    pub results: Vec<DescribeLogDirsResult>,
25    /// Unknown tagged fields.
26    #[cfg_attr(test, proptest(strategy = "proptest_strategies::unknown_tagged_fields()"))]
27    pub _unknown_tagged_fields: Vec<RawTaggedField>,
28}
29
30impl ApiMessage for DescribeLogDirsResponse {
31    fn api_key(&self) -> i16 {
32        35
33    }
34    
35    fn version(&self) -> i16 {
36        3
37    }
38}
39
40impl Response for DescribeLogDirsResponse { }
41
42impl Default for DescribeLogDirsResponse {
43    fn default() -> Self {
44        DescribeLogDirsResponse {
45            throttle_time_ms: 0_i32,
46            error_code: 0_i16,
47            results: Vec::<DescribeLogDirsResult>::new(),
48            _unknown_tagged_fields: Vec::new(),
49        }
50    }
51}
52
53impl DescribeLogDirsResponse {
54    pub fn new(throttle_time_ms: i32, error_code: i16, results: Vec<DescribeLogDirsResult>) -> Self {
55        Self {
56            throttle_time_ms,
57            error_code,
58            results,
59            _unknown_tagged_fields: vec![],
60        }
61    }
62}
63
64#[cfg(test)]
65mod tests_describe_log_dirs_response_new_and_default {
66    use super::*;
67    
68    #[test]
69    fn test() {
70        let d = DescribeLogDirsResponse::new(
71            0_i32,
72            0_i16,
73            Vec::<DescribeLogDirsResult>::new(),
74        );
75        assert_eq!(d, DescribeLogDirsResponse::default());
76    }
77}
78
79impl Readable for DescribeLogDirsResponse {
80    fn read(#[allow(unused)] input: &mut impl Read) -> Result<Self> {
81        let throttle_time_ms = i32::read(input)?;
82        let error_code = i16::read(input)?;
83        let results = read_array::<DescribeLogDirsResult>(input, "results", true)?;
84        let tagged_fields_callback = |tag: i32, _: &[u8]| {
85            match tag {
86                _ => Ok(false)
87            }
88        };
89        let _unknown_tagged_fields = read_tagged_fields(input, tagged_fields_callback)?;
90        Ok(DescribeLogDirsResponse {
91            throttle_time_ms, error_code, results, _unknown_tagged_fields
92        })
93    }
94}
95
96impl Writable for DescribeLogDirsResponse {
97    fn write(&self, #[allow(unused)] output: &mut impl Write) -> Result<()> {
98        self.throttle_time_ms.write(output)?;
99        self.error_code.write(output)?;
100        write_array(output, "self.results", &self.results, true)?;
101        write_tagged_fields(output, &[], &self._unknown_tagged_fields)?;
102        Ok(())
103    }
104}
105
106/// DescribeLogDirsResult, version 3.
107#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
108#[cfg_attr(test, derive(Arbitrary))]
109pub struct DescribeLogDirsResult {
110    /// The error code, or 0 if there was no error.
111    pub error_code: i16,
112    /// The absolute log directory path.
113    #[cfg_attr(test, proptest(strategy = "proptest_strategies::string()"))]
114    pub log_dir: String,
115    /// The topics.
116    #[cfg_attr(test, proptest(strategy = "proptest_strategies::vec()"))]
117    pub topics: Vec<DescribeLogDirsTopic>,
118    /// Unknown tagged fields.
119    #[cfg_attr(test, proptest(strategy = "proptest_strategies::unknown_tagged_fields()"))]
120    pub _unknown_tagged_fields: Vec<RawTaggedField>,
121}
122
123impl Default for DescribeLogDirsResult {
124    fn default() -> Self {
125        DescribeLogDirsResult {
126            error_code: 0_i16,
127            log_dir: String::from(""),
128            topics: Vec::<DescribeLogDirsTopic>::new(),
129            _unknown_tagged_fields: Vec::new(),
130        }
131    }
132}
133
134impl DescribeLogDirsResult {
135    pub fn new<S1: AsRef<str>>(error_code: i16, log_dir: S1, topics: Vec<DescribeLogDirsTopic>) -> Self {
136        Self {
137            error_code,
138            log_dir: log_dir.as_ref().to_string(),
139            topics,
140            _unknown_tagged_fields: vec![],
141        }
142    }
143}
144
145#[cfg(test)]
146mod tests_describe_log_dirs_result_new_and_default {
147    use super::*;
148    
149    #[test]
150    fn test() {
151        let d = DescribeLogDirsResult::new(
152            0_i16,
153            String::from(""),
154            Vec::<DescribeLogDirsTopic>::new(),
155        );
156        assert_eq!(d, DescribeLogDirsResult::default());
157    }
158}
159
160impl Readable for DescribeLogDirsResult {
161    fn read(#[allow(unused)] input: &mut impl Read) -> Result<Self> {
162        let error_code = i16::read(input)?;
163        let log_dir = String::read_ext(input, "log_dir", true)?;
164        let topics = read_array::<DescribeLogDirsTopic>(input, "topics", true)?;
165        let tagged_fields_callback = |tag: i32, _: &[u8]| {
166            match tag {
167                _ => Ok(false)
168            }
169        };
170        let _unknown_tagged_fields = read_tagged_fields(input, tagged_fields_callback)?;
171        Ok(DescribeLogDirsResult {
172            error_code, log_dir, topics, _unknown_tagged_fields
173        })
174    }
175}
176
177impl Writable for DescribeLogDirsResult {
178    fn write(&self, #[allow(unused)] output: &mut impl Write) -> Result<()> {
179        self.error_code.write(output)?;
180        self.log_dir.write_ext(output, "self.log_dir", true)?;
181        write_array(output, "self.topics", &self.topics, true)?;
182        write_tagged_fields(output, &[], &self._unknown_tagged_fields)?;
183        Ok(())
184    }
185}
186
187/// DescribeLogDirsTopic, version 3.
188#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
189#[cfg_attr(test, derive(Arbitrary))]
190pub struct DescribeLogDirsTopic {
191    /// The topic name.
192    #[cfg_attr(test, proptest(strategy = "proptest_strategies::string()"))]
193    pub name: String,
194    /// The partitions.
195    #[cfg_attr(test, proptest(strategy = "proptest_strategies::vec()"))]
196    pub partitions: Vec<DescribeLogDirsPartition>,
197    /// Unknown tagged fields.
198    #[cfg_attr(test, proptest(strategy = "proptest_strategies::unknown_tagged_fields()"))]
199    pub _unknown_tagged_fields: Vec<RawTaggedField>,
200}
201
202impl Default for DescribeLogDirsTopic {
203    fn default() -> Self {
204        DescribeLogDirsTopic {
205            name: String::from(""),
206            partitions: Vec::<DescribeLogDirsPartition>::new(),
207            _unknown_tagged_fields: Vec::new(),
208        }
209    }
210}
211
212impl DescribeLogDirsTopic {
213    pub fn new<S1: AsRef<str>>(name: S1, partitions: Vec<DescribeLogDirsPartition>) -> Self {
214        Self {
215            name: name.as_ref().to_string(),
216            partitions,
217            _unknown_tagged_fields: vec![],
218        }
219    }
220}
221
222#[cfg(test)]
223mod tests_describe_log_dirs_topic_new_and_default {
224    use super::*;
225    
226    #[test]
227    fn test() {
228        let d = DescribeLogDirsTopic::new(
229            String::from(""),
230            Vec::<DescribeLogDirsPartition>::new(),
231        );
232        assert_eq!(d, DescribeLogDirsTopic::default());
233    }
234}
235
236impl Readable for DescribeLogDirsTopic {
237    fn read(#[allow(unused)] input: &mut impl Read) -> Result<Self> {
238        let name = String::read_ext(input, "name", true)?;
239        let partitions = read_array::<DescribeLogDirsPartition>(input, "partitions", true)?;
240        let tagged_fields_callback = |tag: i32, _: &[u8]| {
241            match tag {
242                _ => Ok(false)
243            }
244        };
245        let _unknown_tagged_fields = read_tagged_fields(input, tagged_fields_callback)?;
246        Ok(DescribeLogDirsTopic {
247            name, partitions, _unknown_tagged_fields
248        })
249    }
250}
251
252impl Writable for DescribeLogDirsTopic {
253    fn write(&self, #[allow(unused)] output: &mut impl Write) -> Result<()> {
254        self.name.write_ext(output, "self.name", true)?;
255        write_array(output, "self.partitions", &self.partitions, true)?;
256        write_tagged_fields(output, &[], &self._unknown_tagged_fields)?;
257        Ok(())
258    }
259}
260
261/// DescribeLogDirsPartition, version 3.
262#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
263#[cfg_attr(test, derive(Arbitrary))]
264pub struct DescribeLogDirsPartition {
265    /// The partition index.
266    pub partition_index: i32,
267    /// The size of the log segments in this partition in bytes.
268    pub partition_size: i64,
269    /// The lag of the log's LEO w.r.t. partition's HW (if it is the current log for the partition) or current replica's LEO (if it is the future log for the partition).
270    pub offset_lag: i64,
271    /// True if this log is created by AlterReplicaLogDirsRequest and will replace the current log of the replica in the future.
272    pub is_future_key: bool,
273    /// Unknown tagged fields.
274    #[cfg_attr(test, proptest(strategy = "proptest_strategies::unknown_tagged_fields()"))]
275    pub _unknown_tagged_fields: Vec<RawTaggedField>,
276}
277
278impl Default for DescribeLogDirsPartition {
279    fn default() -> Self {
280        DescribeLogDirsPartition {
281            partition_index: 0_i32,
282            partition_size: 0_i64,
283            offset_lag: 0_i64,
284            is_future_key: false,
285            _unknown_tagged_fields: Vec::new(),
286        }
287    }
288}
289
290impl DescribeLogDirsPartition {
291    pub fn new(partition_index: i32, partition_size: i64, offset_lag: i64, is_future_key: bool) -> Self {
292        Self {
293            partition_index,
294            partition_size,
295            offset_lag,
296            is_future_key,
297            _unknown_tagged_fields: vec![],
298        }
299    }
300}
301
302#[cfg(test)]
303mod tests_describe_log_dirs_partition_new_and_default {
304    use super::*;
305    
306    #[test]
307    fn test() {
308        let d = DescribeLogDirsPartition::new(
309            0_i32,
310            0_i64,
311            0_i64,
312            false,
313        );
314        assert_eq!(d, DescribeLogDirsPartition::default());
315    }
316}
317
318impl Readable for DescribeLogDirsPartition {
319    fn read(#[allow(unused)] input: &mut impl Read) -> Result<Self> {
320        let partition_index = i32::read(input)?;
321        let partition_size = i64::read(input)?;
322        let offset_lag = i64::read(input)?;
323        let is_future_key = bool::read(input)?;
324        let tagged_fields_callback = |tag: i32, _: &[u8]| {
325            match tag {
326                _ => Ok(false)
327            }
328        };
329        let _unknown_tagged_fields = read_tagged_fields(input, tagged_fields_callback)?;
330        Ok(DescribeLogDirsPartition {
331            partition_index, partition_size, offset_lag, is_future_key, _unknown_tagged_fields
332        })
333    }
334}
335
336impl Writable for DescribeLogDirsPartition {
337    fn write(&self, #[allow(unused)] output: &mut impl Write) -> Result<()> {
338        self.partition_index.write(output)?;
339        self.partition_size.write(output)?;
340        self.offset_lag.write(output)?;
341        self.is_future_key.write(output)?;
342        write_tagged_fields(output, &[], &self._unknown_tagged_fields)?;
343        Ok(())
344    }
345}
346
347#[cfg(test)]
348mod tests {
349    use super::*;
350    use proptest::prelude::*;
351    
352    #[test]
353    fn test_java_default() {
354        crate::test_utils::test_java_default::<DescribeLogDirsResponse>("DescribeLogDirsResponse", 3);
355    }
356    
357    proptest! {
358        #[test]
359        fn test_serde(data: DescribeLogDirsResponse) {
360            crate::test_utils::test_serde(&data)?;
361        }
362    }
363    
364    proptest! {
365        #[test]
366        fn test_java_arbitrary(data: DescribeLogDirsResponse) {
367            crate::test_utils::test_java_arbitrary(&data, "DescribeLogDirsResponse", 3);
368        }
369    }
370}