Skip to main content

kafka_client_engine/admin/describe_topic_partitions/outcome/
partition.rs

1//! Stable engine-owned partition facts for one explicit page.
2
3/// One exact partition entry from the explicit broker page.
4#[derive(Clone, Debug, Eq, PartialEq)]
5pub struct AdminDescribeTopicPartition {
6    pub(super) error_code: i16,
7    pub(super) partition_index: i32,
8    pub(super) leader_id: Option<i32>,
9    pub(super) leader_epoch: Option<i32>,
10    pub(super) replicas: Vec<i32>,
11    pub(super) isr: Vec<i32>,
12    pub(super) eligible_leader_replicas: Option<Vec<i32>>,
13    pub(super) last_known_elr: Option<Vec<i32>>,
14    pub(super) offline_replicas: Vec<i32>,
15}
16
17impl AdminDescribeTopicPartition {
18    /// Returns Kafka's exact signed partition error.
19    pub const fn error_code(&self) -> i16 {
20        self.error_code
21    }
22
23    /// Returns the nonnegative partition index.
24    pub const fn partition_index(&self) -> i32 {
25        self.partition_index
26    }
27
28    /// Returns the leader after sentinel normalization.
29    pub const fn leader_id(&self) -> Option<i32> {
30        self.leader_id
31    }
32
33    /// Returns the leader epoch after sentinel normalization.
34    pub const fn leader_epoch(&self) -> Option<i32> {
35        self.leader_epoch
36    }
37
38    /// Returns ordered replica broker IDs.
39    pub fn replicas(&self) -> &[i32] {
40        &self.replicas
41    }
42
43    /// Returns ordered in-sync replica broker IDs.
44    pub fn isr(&self) -> &[i32] {
45        &self.isr
46    }
47
48    /// Returns nullable ordered eligible-leader replica IDs.
49    pub fn eligible_leader_replicas(&self) -> Option<&[i32]> {
50        self.eligible_leader_replicas.as_deref()
51    }
52
53    /// Returns nullable ordered last-known eligible-leader replica IDs.
54    pub fn last_known_elr(&self) -> Option<&[i32]> {
55        self.last_known_elr.as_deref()
56    }
57
58    /// Returns ordered offline replica broker IDs.
59    pub fn offline_replicas(&self) -> &[i32] {
60        &self.offline_replicas
61    }
62
63    /// Consumes every exact partition fact into stable owned parts.
64    #[allow(clippy::type_complexity)]
65    pub fn into_parts(
66        self,
67    ) -> (
68        i16,
69        i32,
70        Option<i32>,
71        Option<i32>,
72        Vec<i32>,
73        Vec<i32>,
74        Option<Vec<i32>>,
75        Option<Vec<i32>>,
76        Vec<i32>,
77    ) {
78        (
79            self.error_code,
80            self.partition_index,
81            self.leader_id,
82            self.leader_epoch,
83            self.replicas,
84            self.isr,
85            self.eligible_leader_replicas,
86            self.last_known_elr,
87            self.offline_replicas,
88        )
89    }
90}