Skip to main content

confluent_kafka/admin/options/
describe_configs_options.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//! Options for `Admin::describe_configs`.
16
17/// Options for `Admin::describe_configs`.
18#[derive(Clone, Debug, Default)]
19#[doc(alias = "org.apache.kafka.clients.admin.DescribeConfigsOptions")]
20pub struct DescribeConfigsOptions {
21    timeout_ms: Option<i32>,
22    include_synonyms: bool,
23    include_documentation: bool,
24}
25
26impl DescribeConfigsOptions {
27    /// Creates default options.
28    #[doc(alias = "org.apache.kafka.clients.admin.DescribeConfigsOptions#DescribeConfigsOptions")]
29    pub fn new() -> Self {
30        Self::default()
31    }
32
33    /// Set the timeout in milliseconds for this operation, or `None` if the default
34    /// API timeout for the `AdminClient` should be used.
35    ///
36    /// # Arguments
37    ///
38    /// - `timeout_ms` - the timeout in milliseconds, or `None` for the default API timeout.
39    ///
40    /// # Returns
41    ///
42    /// This `DescribeConfigsOptions` instance.
43    #[must_use]
44    #[doc(alias = "org.apache.kafka.clients.admin.DescribeConfigsOptions#timeoutMs")]
45    pub fn set_timeout_ms(mut self, timeout_ms: Option<i32>) -> Self {
46        self.timeout_ms = timeout_ms;
47        self
48    }
49
50    /// Returns the timeout in milliseconds for this operation, or `None` if the
51    /// default API timeout for the `AdminClient` should be used.
52    #[doc(alias = "org.apache.kafka.clients.admin.DescribeConfigsOptions#timeoutMs")]
53    pub fn timeout_ms(&self) -> Option<i32> {
54        self.timeout_ms
55    }
56
57    /// Set to true if synonym configs should be returned in the response.
58    ///
59    /// # Arguments
60    ///
61    /// - `include_synonyms` - `true` to return synonym configs.
62    ///
63    /// # Returns
64    ///
65    /// This `DescribeConfigsOptions` instance.
66    #[must_use]
67    #[doc(alias = "org.apache.kafka.clients.admin.DescribeConfigsOptions#includeSynonyms")]
68    pub fn set_include_synonyms(mut self, include_synonyms: bool) -> Self {
69        self.include_synonyms = include_synonyms;
70        self
71    }
72
73    /// Returns true if synonym configs should be returned in the response.
74    #[doc(alias = "org.apache.kafka.clients.admin.DescribeConfigsOptions#includeSynonyms")]
75    pub fn include_synonyms(&self) -> bool {
76        self.include_synonyms
77    }
78
79    /// Set to true if config documentation should be returned in the response.
80    ///
81    /// # Arguments
82    ///
83    /// - `include_documentation` - `true` to return config documentation.
84    ///
85    /// # Returns
86    ///
87    /// This `DescribeConfigsOptions` instance.
88    #[must_use]
89    #[doc(alias = "org.apache.kafka.clients.admin.DescribeConfigsOptions#includeDocumentation")]
90    pub fn set_include_documentation(mut self, include_documentation: bool) -> Self {
91        self.include_documentation = include_documentation;
92        self
93    }
94
95    /// Returns true if config documentation should be returned in the response.
96    #[doc(alias = "org.apache.kafka.clients.admin.DescribeConfigsOptions#includeDocumentation")]
97    pub fn include_documentation(&self) -> bool {
98        self.include_documentation
99    }
100}
101
102#[cfg(test)]
103mod tests {
104    use super::*;
105
106    #[test]
107    fn defaults_match_java() {
108        let options = DescribeConfigsOptions::new();
109        assert_eq!(options.timeout_ms(), None);
110        assert!(!options.include_synonyms());
111        assert!(!options.include_documentation());
112    }
113
114    #[test]
115    fn fluent_setters() {
116        let options = DescribeConfigsOptions::new()
117            .set_include_synonyms(true)
118            .set_include_documentation(true);
119        assert!(options.include_synonyms());
120        assert!(options.include_documentation());
121    }
122}