use core::num::NonZeroI16;
use kafka_client_core::NextFetchOffset;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(crate) enum ListOffsetsIsolation {
ReadUncommitted,
ReadCommitted,
}
impl ListOffsetsIsolation {
pub(super) const fn wire_value(self) -> i8 {
match self {
Self::ReadUncommitted => 0,
Self::ReadCommitted => 1,
}
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(crate) struct ResolvedPosition {
next_offset: NextFetchOffset,
timestamp_ms: Option<i64>,
leader_epoch: Option<i32>,
}
impl ResolvedPosition {
pub(super) const fn new(
next_offset: NextFetchOffset,
timestamp_ms: Option<i64>,
leader_epoch: Option<i32>,
) -> Self {
Self {
next_offset,
timestamp_ms,
leader_epoch,
}
}
pub(crate) const fn next_offset(self) -> NextFetchOffset {
self.next_offset
}
pub(crate) const fn timestamp_ms(self) -> Option<i64> {
self.timestamp_ms
}
pub(crate) const fn leader_epoch(self) -> Option<i32> {
self.leader_epoch
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(crate) enum ListOffsetsOutcome {
Resolved(ResolvedPosition),
BrokerError {
code: NonZeroI16,
},
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(crate) struct NormalizedListOffsetsResponse {
throttle_time_ms: u32,
outcome: ListOffsetsOutcome,
}
impl NormalizedListOffsetsResponse {
pub(super) const fn new(throttle_time_ms: u32, outcome: ListOffsetsOutcome) -> Self {
Self {
throttle_time_ms,
outcome,
}
}
pub(crate) const fn throttle_time_ms(self) -> u32 {
self.throttle_time_ms
}
pub(crate) const fn outcome(self) -> ListOffsetsOutcome {
self.outcome
}
}