Struct rdkafka::producer::BaseRecord [−][src]
A record for the BaseProducer
and ThreadedProducer
.
The BaseRecord
is a structure that can be used to provide a new record to
BaseProducer::send
or ThreadedProducer::send
. Since most fields are
optional, a BaseRecord
can be constructed using the builder pattern.
Examples
This example will create a BaseRecord
with no
DeliveryOpaque
:
let record = BaseRecord::to("topic_name") // destination topic .key(&[1, 2, 3, 4]) // message key .payload("content") // message payload .partition(5); // target partition
The following example will build a similar record, but it will use a number
as the DeliveryOpaque
for the message:
let record = BaseRecord::with_opaque_to("topic_name", 123) // destination topic and message id .key(&[1, 2, 3, 4]) // message key .payload("content") // message payload .partition(5); // target partition
Fields
topic: &'a str
Required destination topic.
partition: Option<i32>
Optional destination partition.
payload: Option<&'a P>
Optional payload.
key: Option<&'a K>
Optional key.
timestamp: Option<i64>
Optional timestamp.
Note that Kafka represents timestamps as the number of milliseconds since the Unix epoch.
headers: Option<OwnedHeaders>
Optional message headers.
delivery_opaque: D
Required delivery opaque (defaults to ()
if not required).
Implementations
impl<'a, K: ToBytes + ?Sized, P: ToBytes + ?Sized, D: IntoOpaque> BaseRecord<'a, K, P, D>
[src]
pub fn with_opaque_to(
topic: &'a str,
delivery_opaque: D
) -> BaseRecord<'a, K, P, D>
[src]
topic: &'a str,
delivery_opaque: D
) -> BaseRecord<'a, K, P, D>
Creates a new record with the specified topic name and delivery opaque.
pub fn partition(self, partition: i32) -> BaseRecord<'a, K, P, D>
[src]
Sets the destination partition of the record.
pub fn payload(self, payload: &'a P) -> BaseRecord<'a, K, P, D>
[src]
Sets the payload of the record.
pub fn key(self, key: &'a K) -> BaseRecord<'a, K, P, D>
[src]
Sets the key of the record.
pub fn timestamp(self, timestamp: i64) -> BaseRecord<'a, K, P, D>
[src]
Sets the timestamp of the record.
Note that Kafka represents timestamps as the number of milliseconds since the Unix epoch.
pub fn headers(self, headers: OwnedHeaders) -> BaseRecord<'a, K, P, D>
[src]
Sets the headers of the record.
impl<'a, K: ToBytes + ?Sized, P: ToBytes + ?Sized> BaseRecord<'a, K, P, ()>
[src]
pub fn to(topic: &'a str) -> BaseRecord<'a, K, P, ()>
[src]
Creates a new record with the specified topic name.
Trait Implementations
impl<'a, K: Debug + ToBytes + ?Sized, P: Debug + ToBytes + ?Sized, D: Debug + IntoOpaque> Debug for BaseRecord<'a, K, P, D>
[src]
Auto Trait Implementations
impl<'a, K: ?Sized, P: ?Sized, D> RefUnwindSafe for BaseRecord<'a, K, P, D> where
D: RefUnwindSafe,
K: RefUnwindSafe,
P: RefUnwindSafe,
D: RefUnwindSafe,
K: RefUnwindSafe,
P: RefUnwindSafe,
impl<'a, K: ?Sized, P: ?Sized, D> Send for BaseRecord<'a, K, P, D> where
K: Sync,
P: Sync,
K: Sync,
P: Sync,
impl<'a, K: ?Sized, P: ?Sized, D> Sync for BaseRecord<'a, K, P, D> where
K: Sync,
P: Sync,
K: Sync,
P: Sync,
impl<'a, K: ?Sized, P: ?Sized, D> Unpin for BaseRecord<'a, K, P, D> where
D: Unpin,
D: Unpin,
impl<'a, K: ?Sized, P: ?Sized, D> UnwindSafe for BaseRecord<'a, K, P, D> where
D: UnwindSafe,
K: RefUnwindSafe,
P: RefUnwindSafe,
D: UnwindSafe,
K: RefUnwindSafe,
P: RefUnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,