use core::fmt;
mod translate;
pub(crate) use translate::translate_terminal;
use super::DescribeShareGroupResult;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum DescribeShareGroupDeliveryStatus {
NotSent,
PossiblySent,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct DescribeShareGroupBrokerError {
pub(super) throttle_time_ms: u32,
pub(super) code: i16,
pub(super) message: Option<String>,
pub(super) message_truncated: bool,
}
impl DescribeShareGroupBrokerError {
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, Debug, Eq, PartialEq)]
pub enum DescribeShareGroupBatchOutcome {
Described(DescribeShareGroupResult),
BrokerRejected {
group_id: String,
error: DescribeShareGroupBrokerError,
},
}
impl DescribeShareGroupBatchOutcome {
pub fn group_id(&self) -> &str {
match self {
Self::Described(result) => {
let description = result.description();
&description.group_id
}
Self::BrokerRejected { group_id, .. } => group_id,
}
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct DescribeShareGroupsBatch {
throttle_time_ms: u32,
outcomes: Vec<DescribeShareGroupBatchOutcome>,
}
impl DescribeShareGroupsBatch {
pub const fn throttle_time_ms(&self) -> u32 {
self.throttle_time_ms
}
pub fn outcomes(&self) -> &[DescribeShareGroupBatchOutcome] {
&self.outcomes
}
pub fn into_parts(self) -> (u32, Vec<DescribeShareGroupBatchOutcome>) {
(self.throttle_time_ms, self.outcomes)
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum DescribeShareGroupFailureKind {
DeadlineElapsed,
DriverRejected,
Transport,
ResponseTooLarge,
Compatibility,
InvalidResponse,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct DescribeShareGroupFailure {
pub(super) kind: DescribeShareGroupFailureKind,
pub(super) delivery: DescribeShareGroupDeliveryStatus,
}
impl DescribeShareGroupFailure {
pub const fn kind(self) -> DescribeShareGroupFailureKind {
self.kind
}
pub const fn delivery(self) -> DescribeShareGroupDeliveryStatus {
self.delivery
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum DescribeShareGroupOutcome {
Described(DescribeShareGroupResult),
BrokerRejected(DescribeShareGroupBrokerError),
Batch(DescribeShareGroupsBatch),
Failed(DescribeShareGroupFailure),
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum DescribeShareGroupObserverError {
AlreadyObserved,
Stale,
}
impl fmt::Display for DescribeShareGroupObserverError {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str(match self {
Self::AlreadyObserved => "Admin DescribeShareGroup result was already observed",
Self::Stale => "Admin DescribeShareGroup observer is stale",
})
}
}
impl std::error::Error for DescribeShareGroupObserverError {}