kafka_wire_protocol/schema/delete_topics_request/
v1.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, Request};
10use crate::readable_writable::{Readable, Writable};
11#[cfg(test)] use crate::test_utils::proptest_strategies;
12
13/// DeleteTopicsRequest, version 1.
14#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
15#[cfg_attr(test, derive(Arbitrary))]
16pub struct DeleteTopicsRequest {
17    /// The names of the topics to delete.
18    #[cfg_attr(test, proptest(strategy = "proptest_strategies::vec()"))]
19    pub topic_names: Vec<String>,
20    /// The length of time in milliseconds to wait for the deletions to complete.
21    pub timeout_ms: i32,
22}
23
24impl ApiMessage for DeleteTopicsRequest {
25    fn api_key(&self) -> i16 {
26        20
27    }
28    
29    fn version(&self) -> i16 {
30        1
31    }
32}
33
34impl Request for DeleteTopicsRequest { }
35
36impl Default for DeleteTopicsRequest {
37    fn default() -> Self {
38        DeleteTopicsRequest {
39            topic_names: Vec::<String>::new(),
40            timeout_ms: 0_i32,
41        }
42    }
43}
44
45impl DeleteTopicsRequest {
46    pub fn new(topic_names: Vec<String>, timeout_ms: i32) -> Self {
47        Self {
48            topic_names,
49            timeout_ms,
50        }
51    }
52}
53
54#[cfg(test)]
55mod tests_delete_topics_request_new_and_default {
56    use super::*;
57    
58    #[test]
59    fn test() {
60        let d = DeleteTopicsRequest::new(
61            Vec::<String>::new(),
62            0_i32,
63        );
64        assert_eq!(d, DeleteTopicsRequest::default());
65    }
66}
67
68impl Readable for DeleteTopicsRequest {
69    fn read(#[allow(unused)] input: &mut impl Read) -> Result<Self> {
70        let topic_names = read_array::<String>(input, "topic_names", false)?;
71        let timeout_ms = i32::read(input)?;
72        Ok(DeleteTopicsRequest {
73            topic_names, timeout_ms
74        })
75    }
76}
77
78impl Writable for DeleteTopicsRequest {
79    fn write(&self, #[allow(unused)] output: &mut impl Write) -> Result<()> {
80        write_array(output, "self.topic_names", &self.topic_names, false)?;
81        self.timeout_ms.write(output)?;
82        Ok(())
83    }
84}
85
86#[cfg(test)]
87mod tests {
88    use super::*;
89    use proptest::prelude::*;
90    
91    #[test]
92    fn test_java_default() {
93        crate::test_utils::test_java_default::<DeleteTopicsRequest>("DeleteTopicsRequest", 1);
94    }
95    
96    proptest! {
97        #[test]
98        fn test_serde(data: DeleteTopicsRequest) {
99            crate::test_utils::test_serde(&data)?;
100        }
101    }
102    
103    proptest! {
104        #[test]
105        fn test_java_arbitrary(data: DeleteTopicsRequest) {
106            crate::test_utils::test_java_arbitrary(&data, "DeleteTopicsRequest", 1);
107        }
108    }
109}