Skip to main content

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