use std::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum CanonicalCondition {
InvalidArgument,
NotFound,
AlreadyExists,
Unauthenticated,
PermissionDenied,
ResourceExhausted,
FailedPrecondition,
Aborted,
Unavailable,
DeadlineExceeded,
DataLoss,
Cancelled,
Unimplemented,
Internal,
}
impl CanonicalCondition {
#[inline]
pub const fn as_str(self) -> &'static str {
match self {
Self::InvalidArgument => "invalid_argument",
Self::NotFound => "not_found",
Self::AlreadyExists => "already_exists",
Self::Unauthenticated => "unauthenticated",
Self::PermissionDenied => "permission_denied",
Self::ResourceExhausted => "resource_exhausted",
Self::FailedPrecondition => "failed_precondition",
Self::Aborted => "aborted",
Self::Unavailable => "unavailable",
Self::DeadlineExceeded => "deadline_exceeded",
Self::DataLoss => "data_loss",
Self::Cancelled => "cancelled",
Self::Unimplemented => "unimplemented",
Self::Internal => "internal",
}
}
}
impl fmt::Display for CanonicalCondition {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum RecoveryHint {
Never,
Backoff,
RefreshRoute,
RefreshLeader,
SwitchBroker,
RefreshCredentials,
OperatorAction,
}
impl RecoveryHint {
#[inline]
pub const fn as_str(self) -> &'static str {
match self {
Self::Never => "never",
Self::Backoff => "backoff",
Self::RefreshRoute => "refresh_route",
Self::RefreshLeader => "refresh_leader",
Self::SwitchBroker => "switch_broker",
Self::RefreshCredentials => "refresh_credentials",
Self::OperatorAction => "operator_action",
}
}
}
impl fmt::Display for RecoveryHint {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_str())
}
}