Skip to main content

kafka_client_engine/admin/
error.rs

1//! Stable immediate `CreateTopics` admission failures.
2
3use core::fmt;
4
5/// Stable category for a request that never crossed admin admission.
6#[derive(Clone, Copy, Debug, Eq, PartialEq)]
7pub enum CreateTopicsAdmissionErrorKind {
8    /// The request violates deterministic `CreateTopics` validation.
9    InvalidRequest,
10    /// The requested timeout is zero or cannot become an absolute deadline.
11    InvalidDeadline,
12    /// The concrete admin shard is briefly owned by another caller or host turn.
13    Contended,
14    /// Admin admission has closed.
15    Closed,
16    /// Bounded operation-completion capacity is full.
17    Capacity,
18    /// The request exceeds the bounded retained-byte budget.
19    RetainedBytes,
20    /// Stable operation identities are exhausted.
21    IdentityExhausted,
22    /// The host's completion mechanism is unavailable.
23    HostUnavailable,
24}
25
26/// Immediate definitely-unsent `CreateTopics` rejection.
27#[derive(Clone, Copy, Debug, Eq, PartialEq)]
28pub struct CreateTopicsAdmissionError {
29    kind: CreateTopicsAdmissionErrorKind,
30}
31
32impl CreateTopicsAdmissionError {
33    pub(crate) const fn new(kind: CreateTopicsAdmissionErrorKind) -> Self {
34        Self { kind }
35    }
36
37    /// Returns the stable rejection category.
38    pub const fn kind(self) -> CreateTopicsAdmissionErrorKind {
39        self.kind
40    }
41}
42
43impl fmt::Display for CreateTopicsAdmissionError {
44    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
45        write!(formatter, "CreateTopics admission failed: {:?}", self.kind)
46    }
47}
48
49impl std::error::Error for CreateTopicsAdmissionError {}