pub enum KonsumerOffsetsData {
OffsetCommit(OffsetCommit),
GroupMetadata(GroupMetadata),
}
Expand description
Possible types of data stored in __consumer_offsets
topic.
This enum is a rust-idiomatic way to handle the fact that the messages read from
__consumer_offsets
can be of different type. Ideally Kafka could have used 2 different
topics, but it doesn’t so… here we are.
Variants§
OffsetCommit(OffsetCommit)
Variant that wraps an OffsetCommit
struct instance.
GroupMetadata(GroupMetadata)
Variant that wraps a GroupMetadata
struct instance.
Implementations§
source§impl KonsumerOffsetsData
impl KonsumerOffsetsData
sourcepub fn try_from_bytes(
key: Option<&[u8]>,
payload: Option<&[u8]>
) -> Result<KonsumerOffsetsData, KonsumerOffsetsError>
pub fn try_from_bytes( key: Option<&[u8]>, payload: Option<&[u8]> ) -> Result<KonsumerOffsetsData, KonsumerOffsetsError>
Parses the content of a messages (a.k.a. records) from the __consumer_offsets
.
__consumer_offsets
it’s a key internal Kafka topic, used by Kafka Consumers to
keep track of the offset consumed so far, and also to coordinate their subscriptions
and partition assignments.
This method returns a KonsumerOffsetsData
: an enum where each variant represents
one of the possible messages that this topic carries.
Refer to the documentation of each variant for details.
NOTE: As Kafka messages have key and payload both optional,
the signature reflects that. But messages of __consumer_offsets
have at least a key set: if absent, the method will return an error.
§Arguments
key
- AnOption
of&[u8]
: when set, it means the source Kafka message has a key. Ifkey
isNone
, this function will return an error: it’s likely that the message it’s not actually from the__consumer_offsets
topic.payload
- AnOption
of&[u8]
: when set, it means the source Kafka message has a payload. Ifpayload
isNone
, the source Kafka message is a tombstone.
sourcepub fn try_from_bytes_vec(
key: Option<Vec<u8>>,
payload: Option<Vec<u8>>
) -> Result<KonsumerOffsetsData, KonsumerOffsetsError>
pub fn try_from_bytes_vec( key: Option<Vec<u8>>, payload: Option<Vec<u8>> ) -> Result<KonsumerOffsetsData, KonsumerOffsetsError>
Same as Self::try_from_bytes
, but handling input as Option<Vec<u8>>
.
Trait Implementations§
source§impl Clone for KonsumerOffsetsData
impl Clone for KonsumerOffsetsData
source§fn clone(&self) -> KonsumerOffsetsData
fn clone(&self) -> KonsumerOffsetsData
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for KonsumerOffsetsData
impl Debug for KonsumerOffsetsData
source§impl PartialEq for KonsumerOffsetsData
impl PartialEq for KonsumerOffsetsData
source§fn eq(&self, other: &KonsumerOffsetsData) -> bool
fn eq(&self, other: &KonsumerOffsetsData) -> bool
self
and other
values to be equal, and is used
by ==
.