kafka_wire_protocol/schema/delete_topics_response/
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, Response};
10use crate::readable_writable::{Readable, Writable};
11#[cfg(test)] use crate::test_utils::proptest_strategies;
12
13/// DeleteTopicsResponse, version 1.
14#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
15#[cfg_attr(test, derive(Arbitrary))]
16pub struct DeleteTopicsResponse {
17    /// 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.
18    pub throttle_time_ms: i32,
19    /// The results for each topic we tried to delete.
20    #[cfg_attr(test, proptest(strategy = "proptest_strategies::vec()"))]
21    pub responses: Vec<DeletableTopicResult>,
22}
23
24impl ApiMessage for DeleteTopicsResponse {
25    fn api_key(&self) -> i16 {
26        20
27    }
28    
29    fn version(&self) -> i16 {
30        1
31    }
32}
33
34impl Response for DeleteTopicsResponse { }
35
36impl Default for DeleteTopicsResponse {
37    fn default() -> Self {
38        DeleteTopicsResponse {
39            throttle_time_ms: 0_i32,
40            responses: Vec::<DeletableTopicResult>::new(),
41        }
42    }
43}
44
45impl DeleteTopicsResponse {
46    pub fn new(throttle_time_ms: i32, responses: Vec<DeletableTopicResult>) -> Self {
47        Self {
48            throttle_time_ms,
49            responses,
50        }
51    }
52}
53
54#[cfg(test)]
55mod tests_delete_topics_response_new_and_default {
56    use super::*;
57    
58    #[test]
59    fn test() {
60        let d = DeleteTopicsResponse::new(
61            0_i32,
62            Vec::<DeletableTopicResult>::new(),
63        );
64        assert_eq!(d, DeleteTopicsResponse::default());
65    }
66}
67
68impl Readable for DeleteTopicsResponse {
69    fn read(#[allow(unused)] input: &mut impl Read) -> Result<Self> {
70        let throttle_time_ms = i32::read(input)?;
71        let responses = read_array::<DeletableTopicResult>(input, "responses", false)?;
72        Ok(DeleteTopicsResponse {
73            throttle_time_ms, responses
74        })
75    }
76}
77
78impl Writable for DeleteTopicsResponse {
79    fn write(&self, #[allow(unused)] output: &mut impl Write) -> Result<()> {
80        self.throttle_time_ms.write(output)?;
81        write_array(output, "self.responses", &self.responses, false)?;
82        Ok(())
83    }
84}
85
86/// DeletableTopicResult, version 1.
87#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
88#[cfg_attr(test, derive(Arbitrary))]
89pub struct DeletableTopicResult {
90    /// The topic name.
91    #[cfg_attr(test, proptest(strategy = "proptest_strategies::string()"))]
92    pub name: String,
93    /// The deletion error, or 0 if the deletion succeeded.
94    pub error_code: i16,
95}
96
97impl Default for DeletableTopicResult {
98    fn default() -> Self {
99        DeletableTopicResult {
100            name: String::from(""),
101            error_code: 0_i16,
102        }
103    }
104}
105
106impl DeletableTopicResult {
107    pub fn new<S1: AsRef<str>>(name: S1, error_code: i16) -> Self {
108        Self {
109            name: name.as_ref().to_string(),
110            error_code,
111        }
112    }
113}
114
115#[cfg(test)]
116mod tests_deletable_topic_result_new_and_default {
117    use super::*;
118    
119    #[test]
120    fn test() {
121        let d = DeletableTopicResult::new(
122            String::from(""),
123            0_i16,
124        );
125        assert_eq!(d, DeletableTopicResult::default());
126    }
127}
128
129impl Readable for DeletableTopicResult {
130    fn read(#[allow(unused)] input: &mut impl Read) -> Result<Self> {
131        let name = String::read_ext(input, "name", false)?;
132        let error_code = i16::read(input)?;
133        Ok(DeletableTopicResult {
134            name, error_code
135        })
136    }
137}
138
139impl Writable for DeletableTopicResult {
140    fn write(&self, #[allow(unused)] output: &mut impl Write) -> Result<()> {
141        self.name.write_ext(output, "self.name", false)?;
142        self.error_code.write(output)?;
143        Ok(())
144    }
145}
146
147#[cfg(test)]
148mod tests {
149    use super::*;
150    use proptest::prelude::*;
151    
152    #[test]
153    fn test_java_default() {
154        crate::test_utils::test_java_default::<DeleteTopicsResponse>("DeleteTopicsResponse", 1);
155    }
156    
157    proptest! {
158        #[test]
159        fn test_serde(data: DeleteTopicsResponse) {
160            crate::test_utils::test_serde(&data)?;
161        }
162    }
163    
164    proptest! {
165        #[test]
166        fn test_java_arbitrary(data: DeleteTopicsResponse) {
167            crate::test_utils::test_java_arbitrary(&data, "DeleteTopicsResponse", 1);
168        }
169    }
170}