pub struct OffsetAndMetadata { /* private fields */ }Expand description
The Kafka offset commit API allows users to provide additional metadata (in the form of a string) when an offset is committed. This can be useful (for example) to store information about which node made the commit, what time the commit was made, etc.
Corresponds to Java’s org.apache.kafka.clients.consumer.OffsetAndMetadata.
Implementations§
Source§impl OffsetAndMetadata
impl OffsetAndMetadata
Sourcepub fn new(offset: i64) -> Result<Self, Error>
pub fn new(offset: i64) -> Result<Self, Error>
Construct a new OffsetAndMetadata with the given offset.
The metadata is set to the empty string and no leader epoch is set.
Corresponds to Java’s new OffsetAndMetadata(long offset).
§Errors
Returns Error::LocalIllegalArgument if offset is negative
(matching Java’s IllegalArgumentException).
Sourcepub fn with_metadata(
offset: i64,
metadata: impl Into<String>,
) -> Result<Self, Error>
pub fn with_metadata( offset: i64, metadata: impl Into<String>, ) -> Result<Self, Error>
Construct a new OffsetAndMetadata with the given offset and metadata.
Corresponds to Java’s new OffsetAndMetadata(long offset, String metadata).
§Errors
Returns Error::LocalIllegalArgument if offset is negative.
Sourcepub fn with_leader_epoch_metadata(
offset: i64,
leader_epoch: Option<i32>,
metadata: impl Into<String>,
) -> Result<Self, Error>
pub fn with_leader_epoch_metadata( offset: i64, leader_epoch: Option<i32>, metadata: impl Into<String>, ) -> Result<Self, Error>
Construct a new OffsetAndMetadata with offset, optional leader epoch,
and metadata.
Corresponds to Java’s
new OffsetAndMetadata(long, Optional<Integer>, String).
§Errors
Returns Error::LocalIllegalArgument if offset is negative.
Sourcepub fn metadata(&self) -> &str
pub fn metadata(&self) -> &str
Returns the metadata associated with the commit, or an empty string if no metadata was provided.
Sourcepub fn leader_epoch(&self) -> Option<i32>
pub fn leader_epoch(&self) -> Option<i32>
Get the leader epoch of the previously consumed record (if one is
known). Negative epochs are filtered to None to match Java’s
leaderEpoch().
Trait Implementations§
Source§impl Clone for OffsetAndMetadata
impl Clone for OffsetAndMetadata
Source§fn clone(&self) -> OffsetAndMetadata
fn clone(&self) -> OffsetAndMetadata
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OffsetAndMetadata
impl Debug for OffsetAndMetadata
Source§impl Display for OffsetAndMetadata
impl Display for OffsetAndMetadata
Source§impl Hash for OffsetAndMetadata
impl Hash for OffsetAndMetadata
Source§impl PartialEq for OffsetAndMetadata
impl PartialEq for OffsetAndMetadata
impl Eq for OffsetAndMetadata
Auto Trait Implementations§
impl Freeze for OffsetAndMetadata
impl RefUnwindSafe for OffsetAndMetadata
impl Send for OffsetAndMetadata
impl Sync for OffsetAndMetadata
impl Unpin for OffsetAndMetadata
impl UnsafeUnpin for OffsetAndMetadata
impl UnwindSafe for OffsetAndMetadata
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.