Skip to main content

ProducerRecordOptionsBuilder

Struct ProducerRecordOptionsBuilder 

Source
pub struct ProducerRecordOptionsBuilder<K, V> { /* private fields */ }
Expand description

Fluent builder for ProducerRecordOptions.

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 ProducerRecordOptions it has no Java counterpart.

Implementations§

Source§

impl<K, V> ProducerRecordOptionsBuilder<K, V>

Source

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.

Source

pub fn set_topic(self, topic: String) -> Self

Sets ProducerRecordOptions::topic, a mandatory parameter: Self::build returns an error if it was not set.

§Arguments
  • topic - the topic the record will be appended to
§Returns

This builder.

Source

pub fn set_partition(self, partition: Option<i32>) -> Self

Sets ProducerRecordOptions::partition.

§Arguments
  • partition - the partition to which the record should be sent
§Returns

This builder.

Source

pub fn set_timestamp(self, timestamp: Option<i64>) -> Self

Sets ProducerRecordOptions::timestamp.

§Arguments
  • timestamp - the timestamp of the record, in milliseconds since epoch
§Returns

This builder.

Source

pub fn set_key(self, key: Option<K>) -> Self

Sets ProducerRecordOptions::key.

§Arguments
  • key - the key that will be included in the record
§Returns

This builder.

Source

pub fn set_value(self, value: Option<V>) -> Self

Sets ProducerRecordOptions::value, a mandatory parameter: Self::build returns an error if it was not set.

§Arguments
  • value - the record contents
§Returns

This builder.

Source

pub fn set_headers(self, headers: Option<RecordHeaders>) -> Self

Sets ProducerRecordOptions::headers.

§Arguments
  • headers - the headers that will be included in the record
§Returns

This builder.

Source

pub fn build(self) -> Result<ProducerRecordOptions<K, V>, Error>

Returns the built options.

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, value.

§Errors
  • Error::is_local_illegal_argument_error, 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.

Trait Implementations§

Source§

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

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<K, V> Freeze for ProducerRecordOptionsBuilder<K, V>
where K: Freeze, V: Freeze,

§

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

§

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

§

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

§

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

§

impl<K, V> UnsafeUnpin for ProducerRecordOptionsBuilder<K, V>
where K: UnsafeUnpin, V: UnsafeUnpin,

§

impl<K, V> UnwindSafe for ProducerRecordOptionsBuilder<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