Skip to main content

ConsumerRecords

Struct ConsumerRecords 

Source
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>

Source

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 partition
  • next_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.

Source

pub fn empty() -> Self

Returns an empty ConsumerRecords instance.

§Returns

An empty ConsumerRecords.

Source

pub fn records_with_partition( &self, partition: &TopicPartition, ) -> &[ConsumerRecord<K, V>]

Get just the records for the given partition.

§Arguments
  • partition - The partition to get records for
§Returns

The records, an empty slice if there are none.

Source

pub fn records_with_topic<'a>( &'a self, topic: &'a str, ) -> impl Iterator<Item = &'a ConsumerRecord<K, V>> + 'a

Get just the records for the given topic.

§Arguments
  • topic - The topic to get records for
§Returns

An iterator over the records, in partition-insertion order.

Source

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.

Source

pub fn count(&self) -> usize

Returns the number of records for all topics.

Source

pub fn is_empty(&self) -> bool

Returns whether this container has any records.

§Returns

True if there are no records, false otherwise

Source

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: Debug, V: Debug> Debug for ConsumerRecords<K, V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<K, V> Default for ConsumerRecords<K, V>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

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>

The type of the elements being iterated over.
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>>>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<K, V> IntoIterator for ConsumerRecords<K, V>

Owned iteration that consumes the ConsumerRecords.

Source§

type Item = ConsumerRecord<K, V>

The type of the elements being iterated over.
Source§

type IntoIter = FlatMap<IntoValues<TopicPartition, Vec<ConsumerRecord<K, V>>>, IntoIter<ConsumerRecord<K, V>>, fn(Vec<ConsumerRecord<K, V>>) -> IntoIter<ConsumerRecord<K, V>>>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<K, V> Freeze for ConsumerRecords<K, V>

§

impl<K, V> RefUnwindSafe for ConsumerRecords<K, V>

§

impl<K, V> Send for ConsumerRecords<K, V>
where K: Send, V: Send,

§

impl<K, V> Sync for ConsumerRecords<K, V>
where K: Sync, V: Sync,

§

impl<K, V> Unpin for ConsumerRecords<K, V>
where K: Unpin, V: Unpin,

§

impl<K, V> UnsafeUnpin for ConsumerRecords<K, V>

§

impl<K, V> UnwindSafe for ConsumerRecords<K, V>
where K: UnwindSafe, V: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V