confluent_kafka/admin/options/describe_features_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_features`.
16
17/// Options for `Admin::describe_features`.
18#[derive(Clone, Debug, Default)]
19#[doc(alias = "org.apache.kafka.clients.admin.DescribeFeaturesOptions")]
20pub struct DescribeFeaturesOptions {
21 timeout_ms: Option<i32>,
22 node_id: Option<i32>,
23}
24
25impl DescribeFeaturesOptions {
26 /// Creates default options (default API timeout, arbitrary node).
27 #[doc(alias = "org.apache.kafka.clients.admin.DescribeFeaturesOptions#DescribeFeaturesOptions")]
28 pub fn new() -> Self {
29 Self::default()
30 }
31
32 /// Set the timeout in milliseconds for this operation, or `None` if the default
33 /// API timeout for the `AdminClient` should be used.
34 ///
35 /// # Arguments
36 ///
37 /// - `timeout_ms` - the timeout in milliseconds, or `None` for the default API timeout.
38 ///
39 /// # Returns
40 ///
41 /// This `DescribeFeaturesOptions` instance.
42 #[must_use]
43 #[doc(alias = "org.apache.kafka.clients.admin.AbstractOptions#timeoutMs")]
44 pub fn set_timeout_ms(mut self, timeout_ms: Option<i32>) -> Self {
45 self.timeout_ms = timeout_ms;
46 self
47 }
48
49 /// Returns the timeout in milliseconds for this operation, or `None` if the
50 /// default API timeout for the `AdminClient` should be used.
51 #[doc(alias = "org.apache.kafka.clients.admin.AbstractOptions#timeoutMs")]
52 pub fn timeout_ms(&self) -> Option<i32> {
53 self.timeout_ms
54 }
55
56 /// Set the node id to which the request should be sent.
57 ///
58 /// # Arguments
59 ///
60 /// - `node_id` - the node id.
61 ///
62 /// # Returns
63 ///
64 /// This `DescribeFeaturesOptions` instance.
65 #[must_use]
66 #[doc(alias = "org.apache.kafka.clients.admin.DescribeFeaturesOptions#nodeId")]
67 pub fn set_node_id(mut self, node_id: i32) -> Self {
68 self.node_id = Some(node_id);
69 self
70 }
71
72 /// The node id to which the request should be sent. If the node id is empty, the request
73 /// will be sent to the arbitrary controller/broker.
74 ///
75 /// # Returns
76 ///
77 /// The node id, or `None` if not set.
78 #[doc(alias = "org.apache.kafka.clients.admin.DescribeFeaturesOptions#nodeId")]
79 pub fn node_id(&self) -> Option<i32> {
80 self.node_id
81 }
82}
83
84#[cfg(test)]
85mod tests {
86 use super::*;
87
88 #[test]
89 fn defaults_match_java() {
90 let options = DescribeFeaturesOptions::new();
91 assert_eq!(options.timeout_ms(), None);
92 assert_eq!(options.node_id(), None);
93 }
94
95 #[test]
96 fn fluent_setters() {
97 let options = DescribeFeaturesOptions::new().set_timeout_ms(Some(100)).set_node_id(0);
98 assert_eq!(options.timeout_ms(), Some(100));
99 assert_eq!(options.node_id(), Some(0));
100 }
101}