use core::fmt;
use super::UnregisterBrokerResult;
mod translate;
pub(crate) use translate::translate_terminal;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum UnregisterBrokerDeliveryStatus {
NotSent,
PossiblySent,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct UnregisterBrokerBrokerError {
pub(super) throttle_time_ms: u32,
pub(super) code: i16,
pub(super) message: Option<String>,
pub(super) message_truncated: bool,
}
impl UnregisterBrokerBrokerError {
pub const fn throttle_time_ms(&self) -> u32 {
self.throttle_time_ms
}
pub const fn code(&self) -> i16 {
self.code
}
pub fn message(&self) -> Option<&str> {
self.message.as_deref()
}
pub const fn message_truncated(&self) -> bool {
self.message_truncated
}
pub fn into_parts(self) -> (u32, i16, Option<String>, bool) {
(
self.throttle_time_ms,
self.code,
self.message,
self.message_truncated,
)
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum UnregisterBrokerFailureKind {
DeadlineElapsed,
DriverRejected,
Transport,
ResponseTooLarge,
Compatibility,
InvalidResponse,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct UnregisterBrokerFailure {
pub(super) kind: UnregisterBrokerFailureKind,
pub(super) delivery: UnregisterBrokerDeliveryStatus,
}
impl UnregisterBrokerFailure {
pub const fn kind(self) -> UnregisterBrokerFailureKind {
self.kind
}
pub const fn delivery(self) -> UnregisterBrokerDeliveryStatus {
self.delivery
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum UnregisterBrokerOutcome {
Unregistered(UnregisterBrokerResult),
BrokerRejected(UnregisterBrokerBrokerError),
Failed(UnregisterBrokerFailure),
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum UnregisterBrokerObserverError {
AlreadyObserved,
Stale,
}
impl fmt::Display for UnregisterBrokerObserverError {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str(match self {
Self::AlreadyObserved => "Admin UnregisterBroker result was already observed",
Self::Stale => "Admin UnregisterBroker observer is stale",
})
}
}
impl std::error::Error for UnregisterBrokerObserverError {}