confluent_kafka/admin/terminate_transaction_result.rs
1// Copyright 2025 Confluent Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! The result of `Admin::force_terminate_transaction`.
16
17use crate::common::KafkaFuture;
18
19/// The result of `Admin::force_terminate_transaction`.
20#[derive(Clone, Debug)]
21#[doc(alias = "org.apache.kafka.clients.admin.TerminateTransactionResult")]
22pub struct TerminateTransactionResult {
23 future: KafkaFuture<()>,
24}
25
26impl TerminateTransactionResult {
27 /// Creates a result wrapping the terminating future.
28 #[doc(alias = "org.apache.kafka.clients.admin.TerminateTransactionResult#TerminateTransactionResult")]
29 pub(crate) fn new(future: KafkaFuture<()>) -> Self {
30 Self { future }
31 }
32
33 /// Returns a future which indicates whether the transaction was successfully
34 /// terminated.
35 #[doc(alias = "org.apache.kafka.clients.admin.TerminateTransactionResult#result")]
36 pub fn result(&self) -> KafkaFuture<()> {
37 self.future.clone()
38 }
39}
40
41#[cfg(test)]
42mod tests {
43 use super::*;
44 use crate::common::internals::KafkaFutureImpl;
45
46 #[tokio::test]
47 async fn result_returns_the_wrapped_future() {
48 let h: KafkaFutureImpl<()> = KafkaFutureImpl::new();
49 let result = TerminateTransactionResult::new(h.future());
50 h.complete(());
51 result.result().get().await.unwrap();
52 }
53}