Skip to main content

confluent_kafka/admin/
describe_log_dirs_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_log_dirs`.
16
17use std::collections::HashMap;
18
19use crate::common::KafkaFuture;
20
21use super::LogDirDescription;
22
23/// The result of the `Admin::describe_log_dirs` call.
24#[derive(Debug)]
25#[doc(alias = "org.apache.kafka.clients.admin.DescribeLogDirsResult")]
26pub struct DescribeLogDirsResult {
27    futures: HashMap<i32, KafkaFuture<HashMap<String, LogDirDescription>>>,
28}
29
30impl DescribeLogDirsResult {
31    /// Creates a new result from the per-broker futures.
32    #[doc(alias = "org.apache.kafka.clients.admin.DescribeLogDirsResult#DescribeLogDirsResult")]
33    pub(crate) fn new(futures: HashMap<i32, KafkaFuture<HashMap<String, LogDirDescription>>>) -> Self {
34        Self { futures }
35    }
36
37    /// Returns a map from broker id to a future which can be used to check the
38    /// information of partitions on each individual broker. The result of the
39    /// future is a map from broker log directory path to a description of that
40    /// log directory.
41    #[doc(alias = "org.apache.kafka.clients.admin.DescribeLogDirsResult#descriptions")]
42    pub fn descriptions(&self) -> &HashMap<i32, KafkaFuture<HashMap<String, LogDirDescription>>> {
43        &self.futures
44    }
45
46    /// Returns a future which succeeds only if all the brokers have responded
47    /// without error, yielding a map from broker id to a map from broker log
48    /// directory path to a description of that log directory.
49    #[doc(alias = "org.apache.kafka.clients.admin.DescribeLogDirsResult#allDescriptions")]
50    pub fn all_descriptions(&self) -> KafkaFuture<HashMap<i32, HashMap<String, LogDirDescription>>> {
51        let entries: Vec<(i32, KafkaFuture<HashMap<String, LogDirDescription>>)> =
52            self.futures.iter().map(|(k, v)| (*k, v.clone())).collect();
53        KafkaFuture::join_map(entries)
54    }
55}