Skip to main content

kafka_client_engine/admin/describe_topic_partitions/
outcome.rs

1//! Stable generated-free terminals for Admin `DescribeTopicPartitions`.
2
3use core::fmt;
4
5mod page;
6mod partition;
7mod topic;
8mod translate;
9
10pub use page::AdminDescribeTopicPartitionsPage;
11pub use partition::AdminDescribeTopicPartition;
12pub use topic::AdminDescribeTopicPartitionsTopic;
13pub(crate) use translate::translate_terminal;
14
15/// Stable delivery certainty independent of core and driver types.
16#[derive(Clone, Copy, Debug, Eq, PartialEq)]
17pub enum AdminDescribeTopicPartitionsDeliveryStatus {
18    /// The failed call did not reach Kafka.
19    NotSent,
20    /// The failed call may have reached Kafka.
21    PossiblySent,
22}
23
24/// Stable whole-operation failure category.
25#[derive(Clone, Copy, Debug, Eq, PartialEq)]
26pub enum AdminDescribeTopicPartitionsFailureKind {
27    /// The original public absolute deadline elapsed.
28    DeadlineElapsed,
29    /// Driver admission rejected the prepared request.
30    DriverRejected,
31    /// Driver-owned transport execution failed.
32    Transport,
33    /// Valid response facts exceeded admitted retained capacity.
34    ResponseTooLarge,
35    /// The selected API version cannot represent required semantics.
36    Compatibility,
37    /// A response was malformed or could not be correlated.
38    InvalidResponse,
39}
40
41/// Whole-operation failure with authoritative delivery certainty.
42#[derive(Clone, Copy, Debug, Eq, PartialEq)]
43pub struct AdminDescribeTopicPartitionsFailure {
44    pub(super) kind: AdminDescribeTopicPartitionsFailureKind,
45    pub(super) delivery: AdminDescribeTopicPartitionsDeliveryStatus,
46}
47
48impl AdminDescribeTopicPartitionsFailure {
49    /// Returns the stable failure category.
50    pub const fn kind(self) -> AdminDescribeTopicPartitionsFailureKind {
51        self.kind
52    }
53
54    /// Returns authoritative delivery certainty.
55    pub const fn delivery(self) -> AdminDescribeTopicPartitionsDeliveryStatus {
56        self.delivery
57    }
58}
59
60/// Exactly one engine-owned one-page terminal decision.
61#[derive(Clone, Debug, Eq, PartialEq)]
62pub enum AdminDescribeTopicPartitionsOutcome {
63    /// Kafka returned one explicit page and optional next cursor.
64    Page(AdminDescribeTopicPartitionsPage),
65    /// Execution failed outside per-topic and per-partition broker facts.
66    Failed(AdminDescribeTopicPartitionsFailure),
67}
68
69/// Failure to observe one named completion.
70#[derive(Clone, Copy, Debug, Eq, PartialEq)]
71pub enum AdminDescribeTopicPartitionsObserverError {
72    /// This linear observer already consumed its terminal.
73    AlreadyObserved,
74    /// The observer generation is no longer live.
75    Stale,
76}
77
78impl fmt::Display for AdminDescribeTopicPartitionsObserverError {
79    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
80        formatter.write_str(match self {
81            Self::AlreadyObserved => "Admin DescribeTopicPartitions result was already observed",
82            Self::Stale => "Admin DescribeTopicPartitions observer is stale",
83        })
84    }
85}
86
87impl std::error::Error for AdminDescribeTopicPartitionsObserverError {}