#![allow(unused)]
use std::borrow::Borrow;
use std::collections::BTreeMap;
use anyhow::{bail, Result};
use bytes::Bytes;
use uuid::Uuid;
use crate::protocol::{
buf::{ByteBuf, ByteBufMut},
compute_unknown_tagged_fields_size, types, write_unknown_tagged_fields, Decodable, Decoder,
Encodable, Encoder, HeaderVersion, Message, StrBytes, VersionRange,
};
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct EndTxnMarker {
pub coordinator_epoch: i32,
}
impl EndTxnMarker {
pub fn with_coordinator_epoch(mut self, value: i32) -> Self {
self.coordinator_epoch = value;
self
}
}
impl Encodable for EndTxnMarker {
fn encode<B: ByteBufMut>(&self, buf: &mut B, version: i16) -> Result<()> {
if version != 0 {
bail!("specified version not supported by this message type");
}
types::Int32.encode(buf, &self.coordinator_epoch)?;
Ok(())
}
fn compute_size(&self, version: i16) -> Result<usize> {
let mut total_size = 0;
total_size += types::Int32.compute_size(&self.coordinator_epoch)?;
Ok(total_size)
}
}
impl Decodable for EndTxnMarker {
fn decode<B: ByteBuf>(buf: &mut B, version: i16) -> Result<Self> {
if version != 0 {
bail!("specified version not supported by this message type");
}
let coordinator_epoch = types::Int32.decode(buf)?;
Ok(Self { coordinator_epoch })
}
}
impl Default for EndTxnMarker {
fn default() -> Self {
Self {
coordinator_epoch: 0,
}
}
}
impl Message for EndTxnMarker {
const VERSIONS: VersionRange = VersionRange { min: 0, max: 0 };
const DEPRECATED_VERSIONS: Option<VersionRange> = None;
}