use kafka_client_core::{ElectLeadersBatch, LeaderElectionBrokerError, LeaderElectionType};
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(crate) struct LeaderElectionRef<'a> {
topic: &'a str,
partition: i32,
}
impl<'a> LeaderElectionRef<'a> {
pub(crate) const fn new(topic: &'a str, partition: i32) -> Self {
Self { topic, partition }
}
pub(crate) const fn topic(self) -> &'a str {
self.topic
}
pub(crate) const fn partition(self) -> i32 {
self.partition
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(crate) enum ElectLeadersSelectionRef<'a> {
AllPartitions,
Selected(&'a [LeaderElectionRef<'a>]),
}
pub(crate) const fn election_type_code(election_type: LeaderElectionType) -> i8 {
match election_type {
LeaderElectionType::Preferred => 0,
LeaderElectionType::Unclean => 1,
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) enum ValidatedElectLeadersResponse {
BrokerRejected(LeaderElectionBrokerError),
Batch(ElectLeadersBatch),
}