Skip to main content

kafka_client_engine/admin/describe_consumer_groups/
assignment.rs

1//! Stable engine assignment values for KIP-848 group descriptions.
2
3/// One topic and its assigned partitions.
4#[derive(Clone, Debug, Eq, PartialEq)]
5pub struct ConsumerGroupTopicPartitions {
6    topic_id: [u8; 16],
7    topic_name: String,
8    partitions: Vec<i32>,
9}
10
11impl ConsumerGroupTopicPartitions {
12    pub(crate) const fn new(topic_id: [u8; 16], topic_name: String, partitions: Vec<i32>) -> Self {
13        Self {
14            topic_id,
15            topic_name,
16            partitions,
17        }
18    }
19
20    /// Consumes this topic assignment into stable parts.
21    pub fn into_parts(self) -> ([u8; 16], String, Vec<i32>) {
22        (self.topic_id, self.topic_name, self.partitions)
23    }
24}
25
26/// One current or target assignment.
27#[derive(Clone, Debug, Eq, PartialEq)]
28pub struct ConsumerGroupAssignment {
29    topics: Vec<ConsumerGroupTopicPartitions>,
30}
31
32impl ConsumerGroupAssignment {
33    pub(crate) const fn new(topics: Vec<ConsumerGroupTopicPartitions>) -> Self {
34        Self { topics }
35    }
36
37    /// Consumes the assignment into canonical topic assignments.
38    pub fn into_topics(self) -> Vec<ConsumerGroupTopicPartitions> {
39        self.topics
40    }
41}