pub struct ConsumerRecords<K, V> { /* private fields */ }Expand description
A container that holds the list ConsumerRecord per partition for a
particular topic. There is one ConsumerRecord list for every topic
partition returned by a Consumer::poll
operation.
Implementations§
Source§impl<K, V> ConsumerRecords<K, V>
impl<K, V> ConsumerRecords<K, V>
Sourcepub fn with_next_offsets(
records: IndexMap<TopicPartition, Vec<ConsumerRecord<K, V>>>,
next_offsets: HashMap<TopicPartition, OffsetAndMetadata>,
) -> Self
pub fn with_next_offsets( records: IndexMap<TopicPartition, Vec<ConsumerRecord<K, V>>>, next_offsets: HashMap<TopicPartition, OffsetAndMetadata>, ) -> Self
Constructs a new ConsumerRecords with the given records and next offsets.
§Arguments
records- The records for each partitionnext_offsets- The next offset and metadata for each partition whose position was advanced during the poll call. These represent the offsets that the consumer will start reading from on the next poll.
§Returns
The new ConsumerRecords.
Sourcepub fn records_with_partition(
&self,
partition: &TopicPartition,
) -> &[ConsumerRecord<K, V>]
pub fn records_with_partition( &self, partition: &TopicPartition, ) -> &[ConsumerRecord<K, V>]
Sourcepub fn records_with_topic<'a>(
&'a self,
topic: &'a str,
) -> impl Iterator<Item = &'a ConsumerRecord<K, V>> + 'a
pub fn records_with_topic<'a>( &'a self, topic: &'a str, ) -> impl Iterator<Item = &'a ConsumerRecord<K, V>> + 'a
Sourcepub fn partitions(&self) -> impl Iterator<Item = &TopicPartition>
pub fn partitions(&self) -> impl Iterator<Item = &TopicPartition>
Get the partitions which have records contained in this record set.
§Returns
The set of partitions with data in this record set (may be empty if no data was returned), as an iterator in insertion order.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns whether this container has any records.
§Returns
True if there are no records, false otherwise
Sourcepub fn next_offsets(&self) -> &HashMap<TopicPartition, OffsetAndMetadata>
pub fn next_offsets(&self) -> &HashMap<TopicPartition, OffsetAndMetadata>
Get the next offsets and metadata corresponding to all topic partitions for which the position have been advanced in this poll call.
§Returns
The next offsets that the consumer will consume
Trait Implementations§
Source§impl<K, V> Default for ConsumerRecords<K, V>
impl<K, V> Default for ConsumerRecords<K, V>
Source§impl<'a, K, V> IntoIterator for &'a ConsumerRecords<K, V>
Borrowed iteration over every record across all partitions (in
partition-insertion order).
impl<'a, K, V> IntoIterator for &'a ConsumerRecords<K, V>
Borrowed iteration over every record across all partitions (in partition-insertion order).
Equivalent to Java’s ConsumerRecords.iterator() (which iterates the
concatenated values of the underlying map).
Source§type Item = &'a ConsumerRecord<K, V>
type Item = &'a ConsumerRecord<K, V>
Source§type IntoIter = FlatMap<Values<'a, TopicPartition, Vec<ConsumerRecord<K, V>>>, Iter<'a, ConsumerRecord<K, V>>, fn(&'a Vec<ConsumerRecord<K, V>>) -> Iter<'a, ConsumerRecord<K, V>>>
type IntoIter = FlatMap<Values<'a, TopicPartition, Vec<ConsumerRecord<K, V>>>, Iter<'a, ConsumerRecord<K, V>>, fn(&'a Vec<ConsumerRecord<K, V>>) -> Iter<'a, ConsumerRecord<K, V>>>
Source§impl<K, V> IntoIterator for ConsumerRecords<K, V>
Owned iteration that consumes the ConsumerRecords.
impl<K, V> IntoIterator for ConsumerRecords<K, V>
Owned iteration that consumes the ConsumerRecords.