pub struct ConsumerRecordOptionsBuilder<K, V> { /* private fields */ }Expand description
Fluent builder for ConsumerRecordOptions.
Per CLAUDE.md §2 Self::new takes no parameters, every parameter has a
fluent setter, and Self::build validates the mandatory ones — returning
Error::LocalIllegalArgument if they were not set. Like ConsumerRecordOptions it has no Java counterpart and
exists solely to satisfy that naming rule (DoD #7).
Implementations§
Source§impl<K, V> ConsumerRecordOptionsBuilder<K, V>
impl<K, V> ConsumerRecordOptionsBuilder<K, V>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a builder with every mandatory parameter unset and every other parameter at the value Java passes on the caller’s behalf.
Sourcepub fn set_topic(self, topic: impl Into<Arc<str>>) -> Self
pub fn set_topic(self, topic: impl Into<Arc<str>>) -> Self
Sets ConsumerRecordOptions::topic, a mandatory parameter: Self::build
panics if it was not set.
Sourcepub fn set_partition(self, partition: i32) -> Self
pub fn set_partition(self, partition: i32) -> Self
Sets ConsumerRecordOptions::partition, a mandatory parameter: Self::build
panics if it was not set.
Sourcepub fn set_offset(self, offset: i64) -> Self
pub fn set_offset(self, offset: i64) -> Self
Sets ConsumerRecordOptions::offset, a mandatory parameter: Self::build
panics if it was not set.
Sourcepub fn set_timestamp(self, timestamp: i64) -> Self
pub fn set_timestamp(self, timestamp: i64) -> Self
Sets ConsumerRecordOptions::timestamp.
Sourcepub fn set_timestamp_type(self, timestamp_type: TimestampType) -> Self
pub fn set_timestamp_type(self, timestamp_type: TimestampType) -> Self
Sets ConsumerRecordOptions::timestamp_type.
Sourcepub fn set_serialized_key_size(self, serialized_key_size: i32) -> Self
pub fn set_serialized_key_size(self, serialized_key_size: i32) -> Self
Sets ConsumerRecordOptions::serialized_key_size.
Sourcepub fn set_serialized_value_size(self, serialized_value_size: i32) -> Self
pub fn set_serialized_value_size(self, serialized_value_size: i32) -> Self
Sets ConsumerRecordOptions::serialized_value_size.
Sourcepub fn set_key(self, key: Option<K>) -> Self
pub fn set_key(self, key: Option<K>) -> Self
Sets ConsumerRecordOptions::key, a mandatory parameter: Self::build
panics if it was not set.
Sourcepub fn set_value(self, value: Option<V>) -> Self
pub fn set_value(self, value: Option<V>) -> Self
Sets ConsumerRecordOptions::value, a mandatory parameter: Self::build
panics if it was not set.
Sourcepub fn set_headers(self, headers: RecordHeaders) -> Self
pub fn set_headers(self, headers: RecordHeaders) -> Self
Sets ConsumerRecordOptions::headers.
Sourcepub fn set_leader_epoch(self, leader_epoch: Option<i32>) -> Self
pub fn set_leader_epoch(self, leader_epoch: Option<i32>) -> Self
Sets ConsumerRecordOptions::leader_epoch.
Sourcepub fn set_delivery_count(self, delivery_count: Option<i16>) -> Self
pub fn set_delivery_count(self, delivery_count: Option<i16>) -> Self
Sets ConsumerRecordOptions::delivery_count.
Sourcepub fn build(self) -> Result<ConsumerRecordOptions<K, V>, Error>
pub fn build(self) -> Result<ConsumerRecordOptions<K, V>, Error>
Returns the built options.
Per CLAUDE.md §2 the mandatory parameters are validated here rather than
being named in the constructor, so a later Java version that makes one of
them optional changes the set this accepts instead of adding a second
constructor. Today there is one mandatory set: topic, partition, offset, key, value.
§Errors
Returns Error::LocalIllegalArgument naming the first parameter of that
set which was not given a setter call. Only presence is checked here;
semantic validation belongs to the method the options are passed to
(CLAUDE.md §2).