Skip to main content

kafka_client_engine/admin/describe_features/
description.rs

1//! Stable generated-free feature metadata returned by Admin `DescribeFeatures`.
2
3/// One broker-supported feature range.
4#[derive(Clone, Debug, Eq, PartialEq)]
5pub struct DescribeFeaturesSupportedFeature {
6    pub(super) name: String,
7    pub(super) min_version: i16,
8    pub(super) max_version: i16,
9}
10
11impl DescribeFeaturesSupportedFeature {
12    /// Returns the exact feature name.
13    pub fn name(&self) -> &str {
14        &self.name
15    }
16
17    /// Returns the broker's minimum supported level.
18    pub const fn min_version(&self) -> i16 {
19        self.min_version
20    }
21
22    /// Returns the broker's maximum supported level.
23    pub const fn max_version(&self) -> i16 {
24        self.max_version
25    }
26
27    /// Consumes this fact into stable scalar parts.
28    pub fn into_parts(self) -> (String, i16, i16) {
29        (self.name, self.min_version, self.max_version)
30    }
31}
32
33/// One cluster-finalized feature range.
34#[derive(Clone, Debug, Eq, PartialEq)]
35pub struct DescribeFeaturesFinalizedFeature {
36    pub(super) name: String,
37    pub(super) min_version_level: i16,
38    pub(super) max_version_level: i16,
39}
40
41impl DescribeFeaturesFinalizedFeature {
42    /// Returns the exact feature name.
43    pub fn name(&self) -> &str {
44        &self.name
45    }
46
47    /// Returns the cluster-wide minimum finalized level.
48    pub const fn min_version_level(&self) -> i16 {
49        self.min_version_level
50    }
51
52    /// Returns the cluster-wide maximum finalized level.
53    pub const fn max_version_level(&self) -> i16 {
54        self.max_version_level
55    }
56
57    /// Consumes this fact into stable scalar parts.
58    pub fn into_parts(self) -> (String, i16, i16) {
59        (self.name, self.min_version_level, self.max_version_level)
60    }
61}
62
63/// Complete bounded feature metadata and Kafka's throttle observation.
64#[derive(Clone, Debug, Eq, PartialEq)]
65pub struct DescribeFeaturesDescription {
66    pub(super) throttle_time_ms: u32,
67    pub(super) supported_features: Vec<DescribeFeaturesSupportedFeature>,
68    pub(super) supported_features_complete: bool,
69    pub(super) finalized_features_epoch: Option<i64>,
70    pub(super) finalized_features: Vec<DescribeFeaturesFinalizedFeature>,
71    pub(super) zk_migration_ready: bool,
72}
73
74impl DescribeFeaturesDescription {
75    /// Returns Kafka's nonnegative throttle observation.
76    pub const fn throttle_time_ms(&self) -> u32 {
77        self.throttle_time_ms
78    }
79
80    /// Reports whether Kafka returned every supported feature, including level-zero entries.
81    pub const fn supported_features_complete(&self) -> bool {
82        self.supported_features_complete
83    }
84
85    /// Returns broker-supported features in strict UTF-8 byte order.
86    pub fn supported_features(&self) -> &[DescribeFeaturesSupportedFeature] {
87        &self.supported_features
88    }
89
90    /// Returns the nonnegative finalized-features epoch, when known.
91    pub const fn finalized_features_epoch(&self) -> Option<i64> {
92        self.finalized_features_epoch
93    }
94
95    /// Returns finalized features in strict UTF-8 byte order.
96    pub fn finalized_features(&self) -> &[DescribeFeaturesFinalizedFeature] {
97        &self.finalized_features
98    }
99
100    /// Reports Kafka's exact `ZooKeeper` migration-readiness fact.
101    pub const fn zk_migration_ready(&self) -> bool {
102        self.zk_migration_ready
103    }
104
105    /// Consumes the description into stable scalar parts.
106    #[allow(clippy::type_complexity)]
107    pub fn into_parts(
108        self,
109    ) -> (
110        u32,
111        Vec<DescribeFeaturesSupportedFeature>,
112        bool,
113        Option<i64>,
114        Vec<DescribeFeaturesFinalizedFeature>,
115        bool,
116    ) {
117        (
118            self.throttle_time_ms,
119            self.supported_features,
120            self.supported_features_complete,
121            self.finalized_features_epoch,
122            self.finalized_features,
123            self.zk_migration_ready,
124        )
125    }
126}