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.
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 object for committing through
KafkaConsumer. The metadata
associated with the commit will be empty.
§Arguments
offset- The offset to be committed
§Returns
The new OffsetAndMetadata.
§Errors
Error::is_local_illegal_argument_errorifoffsetis negative.
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 object for committing through
KafkaConsumer.
§Arguments
offset- The offset to be committedmetadata- Non-null metadata
§Returns
The new OffsetAndMetadata.
§Errors
Error::is_local_illegal_argument_errorifoffsetis 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 object for committing through
KafkaConsumer.
§Arguments
offset- The offset to be committedleader_epoch- Optional leader epoch of the last consumed recordmetadata- Non-null metadata
§Returns
The new OffsetAndMetadata.
§Errors
Error::is_local_illegal_argument_errorifoffsetis negative.
Sourcepub fn metadata(&self) -> &str
pub fn metadata(&self) -> &str
Get the metadata of the previously consumed record.
§Returns
The metadata or empty string if no metadata
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). Log truncation is detected if there exists a leader epoch which is larger than this epoch and begins at an offset earlier than the committed offset.
§Returns
The leader epoch or empty if not known
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.