use core::fmt;
use super::AddRaftVoterResult;
mod translate;
pub(crate) use translate::translate_terminal;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum AddRaftVoterDeliveryStatus {
NotSent,
PossiblySent,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct AddRaftVoterBrokerError {
pub(super) throttle_time_ms: u32,
pub(super) code: i16,
pub(super) message: Option<String>,
pub(super) message_truncated: bool,
}
impl AddRaftVoterBrokerError {
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 AddRaftVoterFailureKind {
DeadlineElapsed,
DriverRejected,
Transport,
ResponseTooLarge,
Compatibility,
InvalidResponse,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct AddRaftVoterFailure {
pub(super) kind: AddRaftVoterFailureKind,
pub(super) delivery: AddRaftVoterDeliveryStatus,
}
impl AddRaftVoterFailure {
pub const fn kind(self) -> AddRaftVoterFailureKind {
self.kind
}
pub const fn delivery(self) -> AddRaftVoterDeliveryStatus {
self.delivery
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum AddRaftVoterOutcome {
Added(AddRaftVoterResult),
BrokerRejected(AddRaftVoterBrokerError),
Failed(AddRaftVoterFailure),
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum AddRaftVoterObserverError {
AlreadyObserved,
Stale,
}
impl fmt::Display for AddRaftVoterObserverError {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str(match self {
Self::AlreadyObserved => "Admin AddRaftVoter result was already observed",
Self::Stale => "Admin AddRaftVoter observer is stale",
})
}
}
impl std::error::Error for AddRaftVoterObserverError {}