crabka_protocol/opt/rustwide/workdir/generated/
EndTxnMarker.owned.rs1use bytes::{Buf, BufMut};
4
5use crate::primitives::fixed::{get_i32, put_i32};
6use crate::{Decode, Encode, ProtocolError, UnknownTaggedFields};
7pub const MIN_VERSION: i16 = 0;
8pub const MAX_VERSION: i16 = 0;
9pub const FLEXIBLE_MIN: i16 = 32767;
10
11#[inline]
12fn is_flexible(version: i16) -> bool { version >= FLEXIBLE_MIN }
13
14#[derive(Debug, Clone, PartialEq, Eq, Default)]
15pub struct EndTxnMarker {
16 pub coordinator_epoch: i32,
17 pub unknown_tagged_fields: UnknownTaggedFields,
18}
19
20impl Encode for EndTxnMarker {
21 fn encode<B: BufMut>(&self, buf: &mut B, version: i16) -> Result<(), ProtocolError> {
22 if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
23 return Err(ProtocolError::SchemaMismatch("EndTxnMarker version out of range"));
24 }
25 let flex = is_flexible(version);
26 if version >= 0 { put_i32(buf, self.coordinator_epoch) }
27 Ok(())
28 }
29 fn encoded_len(&self, version: i16) -> usize {
30 let flex = is_flexible(version);
31 let mut n: usize = 0;
32 if version >= 0 { n += 4; }
33 n
34 }
35}
36
37impl<'de> Decode<'de> for EndTxnMarker {
38 fn decode<B: Buf>(buf: &mut B, version: i16) -> Result<Self, ProtocolError> {
39 if !(MIN_VERSION..=MAX_VERSION).contains(&version) {
40 return Err(ProtocolError::SchemaMismatch("EndTxnMarker version out of range"));
41 }
42 let flex = is_flexible(version);
43 let mut out = Self::default();
44 if version >= 0 { out.coordinator_epoch = get_i32(buf)?; }
45 Ok(out)
46 }
47}
48
49#[must_use]
52#[allow(unused_comparisons)]
53pub fn default_json(version: i16) -> ::serde_json::Value {
54 let mut obj = ::serde_json::Map::new();
55 obj.insert("coordinatorEpoch".to_string(), ::serde_json::json!(0));
56 ::serde_json::Value::Object(obj)
57}