kafka_client_engine/admin/update_features/
outcome.rs1use core::fmt;
4
5mod translate;
6
7pub(crate) use translate::translate_terminal;
8
9#[derive(Clone, Copy, Debug, Eq, PartialEq)]
11pub enum UpdateFeaturesDeliveryStatus {
12 NotSent,
14 PossiblySent,
16}
17
18#[derive(Clone, Debug, Eq, PartialEq)]
20pub struct UpdateFeaturesBrokerError {
21 pub(super) code: i16,
22 pub(super) message: Option<String>,
23 pub(super) message_truncated: bool,
24}
25
26impl UpdateFeaturesBrokerError {
27 pub const fn code(&self) -> i16 {
29 self.code
30 }
31
32 pub fn message(&self) -> Option<&str> {
34 self.message.as_deref()
35 }
36
37 pub const fn message_truncated(&self) -> bool {
39 self.message_truncated
40 }
41
42 pub fn into_parts(self) -> (i16, Option<String>, bool) {
44 (self.code, self.message, self.message_truncated)
45 }
46}
47
48#[derive(Clone, Debug, Eq, PartialEq)]
50pub enum UpdateFeatureResult {
51 Updated,
53 Failed(UpdateFeaturesBrokerError),
55}
56
57#[derive(Clone, Debug, Eq, PartialEq)]
59pub struct UpdateFeatureOutcome {
60 pub(super) feature: String,
61 pub(super) result: UpdateFeatureResult,
62}
63
64impl UpdateFeatureOutcome {
65 pub fn feature(&self) -> &str {
67 &self.feature
68 }
69
70 pub const fn result(&self) -> &UpdateFeatureResult {
72 &self.result
73 }
74
75 pub fn into_parts(self) -> (String, UpdateFeatureResult) {
77 (self.feature, self.result)
78 }
79}
80
81#[derive(Clone, Debug, Eq, PartialEq)]
83pub struct UpdateFeaturesBatch {
84 pub(super) throttle_time_ms: u32,
85 pub(super) outcomes: Vec<UpdateFeatureOutcome>,
86}
87
88impl UpdateFeaturesBatch {
89 pub const fn throttle_time_ms(&self) -> u32 {
91 self.throttle_time_ms
92 }
93
94 pub fn outcomes(&self) -> &[UpdateFeatureOutcome] {
96 &self.outcomes
97 }
98
99 pub fn into_parts(self) -> (u32, Vec<UpdateFeatureOutcome>) {
101 (self.throttle_time_ms, self.outcomes)
102 }
103}
104
105#[derive(Clone, Debug, Eq, PartialEq)]
107pub enum UpdateFeaturesFailureKind {
108 DeadlineElapsed,
110 DriverRejected,
112 Transport,
114 Broker(UpdateFeaturesBrokerError),
116 ResponseTooLarge,
118 Compatibility,
120 InvalidResponse,
122}
123
124#[derive(Clone, Debug, Eq, PartialEq)]
126pub struct UpdateFeaturesFailure {
127 pub(super) kind: UpdateFeaturesFailureKind,
128 pub(super) delivery: UpdateFeaturesDeliveryStatus,
129}
130
131impl UpdateFeaturesFailure {
132 pub const fn kind(&self) -> &UpdateFeaturesFailureKind {
134 &self.kind
135 }
136
137 pub const fn delivery(&self) -> UpdateFeaturesDeliveryStatus {
139 self.delivery
140 }
141}
142
143#[derive(Clone, Debug, Eq, PartialEq)]
145pub enum UpdateFeaturesOutcome {
146 Updated(UpdateFeaturesBatch),
148 Failed(UpdateFeaturesFailure),
150}
151
152#[derive(Clone, Copy, Debug, Eq, PartialEq)]
154pub enum UpdateFeaturesObserverError {
155 AlreadyObserved,
157 Stale,
159}
160
161impl fmt::Display for UpdateFeaturesObserverError {
162 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
163 formatter.write_str(match self {
164 Self::AlreadyObserved => "Admin UpdateFeatures result was already observed",
165 Self::Stale => "Admin UpdateFeatures observer is stale",
166 })
167 }
168}
169
170impl std::error::Error for UpdateFeaturesObserverError {}