kafka_protocol/messages/
end_txn_marker.rs1#![allow(unused)]
6
7use std::borrow::Borrow;
8use std::collections::BTreeMap;
9
10use anyhow::{bail, Result};
11use bytes::Bytes;
12use uuid::Uuid;
13
14use crate::protocol::{
15 buf::{ByteBuf, ByteBufMut},
16 compute_unknown_tagged_fields_size, types, write_unknown_tagged_fields, Decodable, Decoder,
17 Encodable, Encoder, HeaderVersion, Message, StrBytes, VersionRange,
18};
19
20#[non_exhaustive]
22#[derive(Debug, Clone, PartialEq)]
23pub struct EndTxnMarker {
24 pub coordinator_epoch: i32,
28}
29
30impl EndTxnMarker {
31 pub fn with_coordinator_epoch(mut self, value: i32) -> Self {
37 self.coordinator_epoch = value;
38 self
39 }
40}
41
42impl Encodable for EndTxnMarker {
43 fn encode<B: ByteBufMut>(&self, buf: &mut B, version: i16) -> Result<()> {
44 if version != 0 {
45 bail!("specified version not supported by this message type");
46 }
47 types::Int32.encode(buf, &self.coordinator_epoch)?;
48
49 Ok(())
50 }
51 fn compute_size(&self, version: i16) -> Result<usize> {
52 let mut total_size = 0;
53 total_size += types::Int32.compute_size(&self.coordinator_epoch)?;
54
55 Ok(total_size)
56 }
57}
58
59impl Decodable for EndTxnMarker {
60 fn decode<B: ByteBuf>(buf: &mut B, version: i16) -> Result<Self> {
61 if version != 0 {
62 bail!("specified version not supported by this message type");
63 }
64 let coordinator_epoch = types::Int32.decode(buf)?;
65 Ok(Self { coordinator_epoch })
66 }
67}
68
69impl Default for EndTxnMarker {
70 fn default() -> Self {
71 Self {
72 coordinator_epoch: 0,
73 }
74 }
75}
76
77impl Message for EndTxnMarker {
78 const VERSIONS: VersionRange = VersionRange { min: 0, max: 0 };
79 const DEPRECATED_VERSIONS: Option<VersionRange> = None;
80}