use core::fmt;
use super::CreateDelegationTokenResult;
mod translate;
pub(crate) use translate::translate_terminal;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum CreateDelegationTokenDeliveryStatus {
NotSent,
PossiblySent,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct CreateDelegationTokenBrokerError {
pub(super) throttle_time_ms: u32,
pub(super) code: i16,
}
impl CreateDelegationTokenBrokerError {
pub const fn throttle_time_ms(self) -> u32 {
self.throttle_time_ms
}
pub const fn code(self) -> i16 {
self.code
}
pub const fn into_parts(self) -> (u32, i16) {
(self.throttle_time_ms, self.code)
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum CreateDelegationTokenFailureKind {
DeadlineElapsed,
DriverRejected,
Transport,
ResponseTooLarge,
Compatibility,
InvalidResponse,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct CreateDelegationTokenFailure {
pub(super) kind: CreateDelegationTokenFailureKind,
pub(super) delivery: CreateDelegationTokenDeliveryStatus,
}
impl CreateDelegationTokenFailure {
pub const fn kind(self) -> CreateDelegationTokenFailureKind {
self.kind
}
pub const fn delivery(self) -> CreateDelegationTokenDeliveryStatus {
self.delivery
}
}
#[derive(Debug, Eq, PartialEq)]
pub enum CreateDelegationTokenOutcome {
Created(CreateDelegationTokenResult),
BrokerRejected(CreateDelegationTokenBrokerError),
Failed(CreateDelegationTokenFailure),
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum CreateDelegationTokenObserverError {
AlreadyObserved,
Stale,
}
impl fmt::Display for CreateDelegationTokenObserverError {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter.write_str(match self {
Self::AlreadyObserved => "Admin CreateDelegationToken result was already observed",
Self::Stale => "Admin CreateDelegationToken observer is stale",
})
}
}
impl std::error::Error for CreateDelegationTokenObserverError {}