Skip to main content

confluent_kafka/admin/
create_acls_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::create_acls`.
16
17use std::collections::HashMap;
18
19use crate::common::KafkaFuture;
20use crate::common::acl::AclBinding;
21
22/// The result of the `Admin::create_acls` call.
23#[derive(Clone, Debug)]
24#[doc(alias = "org.apache.kafka.clients.admin.CreateAclsResult")]
25pub struct CreateAclsResult {
26    futures: HashMap<AclBinding, KafkaFuture<()>>,
27}
28
29impl CreateAclsResult {
30    /// Creates a new result from the per-binding futures.
31    #[doc(alias = "org.apache.kafka.clients.admin.CreateAclsResult#CreateAclsResult")]
32    pub(crate) fn new(futures: HashMap<AclBinding, KafkaFuture<()>>) -> Self {
33        Self { futures }
34    }
35
36    /// Returns a map from ACL bindings to futures which can be used to check the
37    /// status of the creation of each ACL binding.
38    #[doc(alias = "org.apache.kafka.clients.admin.CreateAclsResult#values")]
39    pub fn values(&self) -> &HashMap<AclBinding, KafkaFuture<()>> {
40        &self.futures
41    }
42
43    /// Returns a future which succeeds only if all the ACL creations succeed.
44    #[doc(alias = "org.apache.kafka.clients.admin.CreateAclsResult#all")]
45    pub fn all(&self) -> KafkaFuture<()> {
46        KafkaFuture::all_of(self.futures.values().cloned().collect())
47    }
48}