#[non_exhaustive]pub struct ProducerRecordOptions<K, V> { /* private fields */ }Expand description
The parameters of Java’s widest ProducerRecord constructor
(ProducerRecord(String, Integer, Long, K, V, Iterable<Header>),
ProducerRecord#ProducerRecord).
This struct has no Java counterpart. It exists because a method taking
more than three parameters beyond the overload group’s intersection takes a
single options struct instead: that constructor
differs from the group’s intersection {topic, value} by four parameters
— partition, timestamp, key, headers — so this
struct becomes the method’s only parameter, carrying every Java
parameter including the intersection’s own.
It deliberately has no Default. topic and value are what even
Java’s narrowest constructor (ProducerRecord#ProducerRecord(String,Object)) takes from its caller, so neither has
a Java-derived default — and a synthesised empty topic would silently send
the record nowhere. Construct it with ProducerRecordOptionsBuilder::new
and set them: ProducerRecordOptionsBuilder::build returns an error if any of topic, value was not set.