Skip to main content

kafka_client_engine/admin/configs/
outcome.rs

1//! Engine-owned terminal values from one ordered `DescribeConfigs` batch.
2
3/// Stable admin delivery certainty independent of core types.
4#[derive(Clone, Copy, Debug, Eq, PartialEq)]
5pub enum DescribeConfigsDeliveryStatus {
6    /// The request definitely did not reach Kafka.
7    NotSent,
8    /// The request may have reached Kafka.
9    PossiblySent,
10}
11
12/// One deterministic configuration synonym.
13#[derive(Clone, Debug, Eq, PartialEq)]
14pub struct DescribeConfigSynonym {
15    pub(super) name: String,
16    pub(super) value: Option<String>,
17    pub(super) source: i8,
18}
19
20impl DescribeConfigSynonym {
21    /// Consumes this synonym into stable adapter-owned parts.
22    pub fn into_parts(self) -> (String, Option<String>, i8) {
23        (self.name, self.value, self.source)
24    }
25}
26
27/// One normalized Kafka configuration entry.
28#[derive(Clone, Debug, Eq, PartialEq)]
29pub struct DescribeConfigEntry {
30    pub(super) name: String,
31    pub(super) value: Option<String>,
32    pub(super) read_only: bool,
33    pub(super) source: i8,
34    pub(super) sensitive: bool,
35    pub(super) synonyms: Vec<DescribeConfigSynonym>,
36    pub(super) config_type: Option<i8>,
37    pub(super) documentation: Option<String>,
38}
39
40impl DescribeConfigEntry {
41    /// Returns the configuration name.
42    pub fn name(&self) -> &str {
43        &self.name
44    }
45
46    /// Returns the nullable configuration value.
47    pub fn value(&self) -> Option<&str> {
48        self.value.as_deref()
49    }
50
51    /// Returns whether Kafka marks this configuration read-only.
52    pub const fn read_only(&self) -> bool {
53        self.read_only
54    }
55
56    /// Returns Kafka's exact signed configuration source.
57    pub const fn source(&self) -> i8 {
58        self.source
59    }
60
61    /// Returns whether Kafka marks the value sensitive.
62    pub const fn sensitive(&self) -> bool {
63        self.sensitive
64    }
65
66    /// Returns deterministic configuration synonyms.
67    pub fn synonyms(&self) -> &[DescribeConfigSynonym] {
68        &self.synonyms
69    }
70
71    /// Returns the field present in `DescribeConfigs` v3 and newer.
72    pub const fn config_type(&self) -> Option<i8> {
73        self.config_type
74    }
75
76    /// Returns version-present nullable documentation.
77    pub fn documentation(&self) -> Option<&str> {
78        self.documentation.as_deref()
79    }
80
81    /// Consumes this entry into stable adapter-owned parts.
82    #[allow(clippy::type_complexity)]
83    pub fn into_parts(
84        self,
85    ) -> (
86        String,
87        Option<String>,
88        bool,
89        i8,
90        bool,
91        Vec<DescribeConfigSynonym>,
92        Option<i8>,
93        Option<String>,
94    ) {
95        (
96            self.name,
97            self.value,
98            self.read_only,
99            self.source,
100            self.sensitive,
101            self.synonyms,
102            self.config_type,
103            self.documentation,
104        )
105    }
106}
107
108/// Exact broker-declared resource rejection.
109#[derive(Clone, Debug, Eq, PartialEq)]
110pub struct DescribeConfigResourceError {
111    pub(super) code: i16,
112    pub(super) message: Option<String>,
113    pub(super) message_truncated: bool,
114}
115
116impl DescribeConfigResourceError {
117    /// Returns Kafka's exact signed error code.
118    pub const fn code(&self) -> i16 {
119        self.code
120    }
121
122    /// Returns the nullable bounded broker diagnostic.
123    pub fn message(&self) -> Option<&str> {
124        self.message.as_deref()
125    }
126
127    /// Returns whether the diagnostic was truncated.
128    pub const fn message_truncated(&self) -> bool {
129        self.message_truncated
130    }
131
132    /// Consumes this broker rejection into stable adapter-owned parts.
133    pub fn into_parts(self) -> (i16, Option<String>, bool) {
134        (self.code, self.message, self.message_truncated)
135    }
136}
137
138/// One requested resource result in original order.
139#[derive(Clone, Debug, Eq, PartialEq)]
140pub struct DescribeConfigResourceResult {
141    pub(super) resource_type: i8,
142    pub(super) resource_name: String,
143    pub(super) result: Result<Vec<DescribeConfigEntry>, DescribeConfigResourceError>,
144}
145
146impl DescribeConfigResourceResult {
147    /// Consumes the ordered result into stable adapter-owned parts.
148    pub fn into_parts(
149        self,
150    ) -> (
151        i8,
152        String,
153        Result<Vec<DescribeConfigEntry>, DescribeConfigResourceError>,
154    ) {
155        (self.resource_type, self.resource_name, self.result)
156    }
157}
158
159/// Successful ordered response plus Kafka's throttle observation.
160#[derive(Clone, Debug, Eq, PartialEq)]
161pub struct DescribeConfigsBatch {
162    pub(super) throttle_time_ms: u32,
163    pub(super) resources: Vec<DescribeConfigResourceResult>,
164}
165
166impl DescribeConfigsBatch {
167    /// Returns Kafka's nonnegative throttle observation.
168    pub const fn throttle_time_ms(&self) -> u32 {
169        self.throttle_time_ms
170    }
171
172    /// Consumes the response into its ordered resource results.
173    pub fn into_resources(self) -> Vec<DescribeConfigResourceResult> {
174        self.resources
175    }
176}
177
178/// Stable whole-operation failure category.
179#[derive(Clone, Copy, Debug, Eq, PartialEq)]
180pub enum DescribeConfigsFailureKind {
181    /// The original deadline elapsed.
182    DeadlineElapsed,
183    /// The generated request was rejected before driver ownership.
184    DriverRejected,
185    /// Driver-owned transport execution failed.
186    Transport,
187    /// The broker response could not be correlated.
188    InvalidResponse,
189    /// A valid response exceeded admitted result capacity.
190    ResponseTooLarge,
191    /// The selected API version cannot represent the requested semantics.
192    Compatibility,
193}
194
195/// Whole-operation failure with authoritative delivery certainty.
196#[derive(Clone, Copy, Debug, Eq, PartialEq)]
197pub struct DescribeConfigsFailure {
198    pub(super) kind: DescribeConfigsFailureKind,
199    pub(super) delivery: DescribeConfigsDeliveryStatus,
200}
201
202impl DescribeConfigsFailure {
203    /// Returns the stable failure category.
204    pub const fn kind(self) -> DescribeConfigsFailureKind {
205        self.kind
206    }
207
208    /// Returns authoritative delivery certainty.
209    pub const fn delivery(self) -> DescribeConfigsDeliveryStatus {
210        self.delivery
211    }
212}
213
214/// Exactly one engine-owned terminal decision.
215#[derive(Clone, Debug, Eq, PartialEq)]
216pub enum DescribeConfigsOutcome {
217    /// Ordered broker outcomes and throttle observation.
218    Configs(DescribeConfigsBatch),
219    /// Whole-operation failure.
220    Failed(DescribeConfigsFailure),
221}