kafka_wire_protocol/schema/end_txn_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::markers::{ApiMessage, Response};
9use crate::readable_writable::{Readable, Writable};
10
11/// EndTxnResponse, version 0.
12#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
13#[cfg_attr(test, derive(Arbitrary))]
14pub struct EndTxnResponse {
15    /// 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.
16    pub throttle_time_ms: i32,
17    /// The error code, or 0 if there was no error.
18    pub error_code: i16,
19}
20
21impl ApiMessage for EndTxnResponse {
22    fn api_key(&self) -> i16 {
23        26
24    }
25    
26    fn version(&self) -> i16 {
27        0
28    }
29}
30
31impl Response for EndTxnResponse { }
32
33impl Default for EndTxnResponse {
34    fn default() -> Self {
35        EndTxnResponse {
36            throttle_time_ms: 0_i32,
37            error_code: 0_i16,
38        }
39    }
40}
41
42impl EndTxnResponse {
43    pub fn new(throttle_time_ms: i32, error_code: i16) -> Self {
44        Self {
45            throttle_time_ms,
46            error_code,
47        }
48    }
49}
50
51#[cfg(test)]
52mod tests_end_txn_response_new_and_default {
53    use super::*;
54    
55    #[test]
56    fn test() {
57        let d = EndTxnResponse::new(
58            0_i32,
59            0_i16,
60        );
61        assert_eq!(d, EndTxnResponse::default());
62    }
63}
64
65impl Readable for EndTxnResponse {
66    fn read(#[allow(unused)] input: &mut impl Read) -> Result<Self> {
67        let throttle_time_ms = i32::read(input)?;
68        let error_code = i16::read(input)?;
69        Ok(EndTxnResponse {
70            throttle_time_ms, error_code
71        })
72    }
73}
74
75impl Writable for EndTxnResponse {
76    fn write(&self, #[allow(unused)] output: &mut impl Write) -> Result<()> {
77        self.throttle_time_ms.write(output)?;
78        self.error_code.write(output)?;
79        Ok(())
80    }
81}
82
83#[cfg(test)]
84mod tests {
85    use super::*;
86    use proptest::prelude::*;
87    
88    #[test]
89    fn test_java_default() {
90        crate::test_utils::test_java_default::<EndTxnResponse>("EndTxnResponse", 0);
91    }
92    
93    proptest! {
94        #[test]
95        fn test_serde(data: EndTxnResponse) {
96            crate::test_utils::test_serde(&data)?;
97        }
98    }
99    
100    proptest! {
101        #[test]
102        fn test_java_arbitrary(data: EndTxnResponse) {
103            crate::test_utils::test_java_arbitrary(&data, "EndTxnResponse", 0);
104        }
105    }
106}