Skip to main content

confluent_kafka/admin/
describe_classic_groups_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::describe_classic_groups`.
16
17use std::collections::HashMap;
18
19use crate::admin::ClassicGroupDescription;
20use crate::common::KafkaFuture;
21
22/// The result of `Admin::describe_classic_groups`.
23#[derive(Clone, Debug)]
24#[doc(alias = "org.apache.kafka.clients.admin.DescribeClassicGroupsResult")]
25pub struct DescribeClassicGroupsResult {
26    futures: HashMap<String, KafkaFuture<ClassicGroupDescription>>,
27}
28
29impl DescribeClassicGroupsResult {
30    /// Creates a result from the per-group-id futures.
31    ///
32    /// # Arguments
33    ///
34    /// - `futures` - the future of each group id.
35    #[doc(alias = "org.apache.kafka.clients.admin.DescribeClassicGroupsResult#DescribeClassicGroupsResult")]
36    pub fn new(futures: HashMap<String, KafkaFuture<ClassicGroupDescription>>) -> Self {
37        Self { futures }
38    }
39
40    /// Returns a map from group id to futures yielding group descriptions.
41    #[doc(alias = "org.apache.kafka.clients.admin.DescribeClassicGroupsResult#describedGroups")]
42    pub fn described_groups(&self) -> HashMap<String, KafkaFuture<ClassicGroupDescription>> {
43        self.futures.clone()
44    }
45
46    /// Returns a future yielding all descriptions if all describes succeed.
47    #[doc(alias = "org.apache.kafka.clients.admin.DescribeClassicGroupsResult#all")]
48    pub fn all(&self) -> KafkaFuture<HashMap<String, ClassicGroupDescription>> {
49        KafkaFuture::join_map(self.futures.iter().map(|(k, v)| (k.clone(), v.clone())).collect())
50    }
51}