Struct rdkafka::producer::base_producer::BaseRecord[][src]

pub struct BaseRecord<'a, K: ToBytes + ?Sized = (), P: ToBytes + ?Sized = (), D: IntoOpaque = ()> {
    pub topic: &'a str,
    pub partition: Option<i32>,
    pub payload: Option<&'a P>,
    pub key: Option<&'a K>,
    pub timestamp: Option<i64>,
    pub headers: Option<OwnedHeaders>,
    pub delivery_opaque: D,
}
Expand description

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

Creates a new record with the specified topic name and delivery opaque.

Sets the destination partition of the record.

Sets the payload of the record.

Sets the key of the record.

Sets the timestamp of the record.

Note that Kafka represents timestamps as the number of milliseconds since the Unix epoch.

Sets the headers of the record.

Creates a new record with the specified topic name.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.