Skip to main content

confluent_kafka/admin/
describe_cluster_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_cluster`.
16
17use std::collections::BTreeSet;
18
19use crate::common::acl::AclOperation;
20use crate::common::{KafkaFuture, Node};
21
22/// The result of the `Admin::describe_cluster` call.
23#[derive(Debug)]
24#[doc(alias = "org.apache.kafka.clients.admin.DescribeClusterResult")]
25pub struct DescribeClusterResult {
26    nodes: KafkaFuture<Vec<Node>>,
27    controller: KafkaFuture<Option<Node>>,
28    cluster_id: KafkaFuture<String>,
29    authorized_operations: KafkaFuture<Option<BTreeSet<AclOperation>>>,
30}
31
32impl DescribeClusterResult {
33    /// Creates a new result from the four per-attribute futures.
34    #[doc(alias = "org.apache.kafka.clients.admin.DescribeClusterResult#DescribeClusterResult")]
35    pub(crate) fn new(
36        nodes: KafkaFuture<Vec<Node>>,
37        controller: KafkaFuture<Option<Node>>,
38        cluster_id: KafkaFuture<String>,
39        authorized_operations: KafkaFuture<Option<BTreeSet<AclOperation>>>,
40    ) -> Self {
41        Self { nodes, controller, cluster_id, authorized_operations }
42    }
43
44    /// Returns a future which yields a collection of nodes in the cluster.
45    #[doc(alias = "org.apache.kafka.clients.admin.DescribeClusterResult#nodes")]
46    pub fn nodes(&self) -> KafkaFuture<Vec<Node>> {
47        self.nodes.clone()
48    }
49
50    /// Returns a future which yields the current controller node, or `None` if there is no
51    /// current controller.
52    ///
53    /// When using `bootstrap.servers`, the controller refer to a random broker.
54    #[doc(alias = "org.apache.kafka.clients.admin.DescribeClusterResult#controller")]
55    pub fn controller(&self) -> KafkaFuture<Option<Node>> {
56        self.controller.clone()
57    }
58
59    /// Returns a future which yields the id of the cluster.
60    #[doc(alias = "org.apache.kafka.clients.admin.DescribeClusterResult#clusterId")]
61    pub fn cluster_id(&self) -> KafkaFuture<String> {
62        self.cluster_id.clone()
63    }
64
65    /// Returns a future which yields the authorized operations of the cluster.
66    ///
67    /// The value is `None` if the operations were not requested or the broker
68    /// omitted them.
69    #[doc(alias = "org.apache.kafka.clients.admin.DescribeClusterResult#authorizedOperations")]
70    pub fn authorized_operations(&self) -> KafkaFuture<Option<BTreeSet<AclOperation>>> {
71        self.authorized_operations.clone()
72    }
73}