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

pub struct BaseRecord<'a, K: ToBytes + ?Sized + 'a = (), P: ToBytes + ?Sized + 'a = (), 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,
}

Producer record for the base producer

The BaseRecord is a structure that can be used to provide a new record to BaseProducer::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 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

headers: Option<OwnedHeaders>

Optional message headers

delivery_opaque: D

Required delivery opaque (defaults to () if not required)

Methods

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]

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

pub fn partition(self, partition: i32) -> BaseRecord<'a, K, P, D>[src]

Set the destination partition of the record.

pub fn payload(self, payload: &'a P) -> BaseRecord<'a, K, P, D>[src]

Set the payload of the record.

pub fn key(self, key: &'a K) -> BaseRecord<'a, K, P, D>[src]

Set the key of the record.

pub fn timestamp(self, timestamp: i64) -> BaseRecord<'a, K, P, D>[src]

Set the timestamp of the record.

pub fn headers(self, headers: OwnedHeaders) -> BaseRecord<'a, K, P, D>[src]

Set 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]

Create a new record with the specified topic name.

Trait Implementations

impl<'a, K: Debug + ToBytes + ?Sized + 'a, P: Debug + ToBytes + ?Sized + 'a, 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

impl<'a, K: ?Sized, P: ?Sized, D> Send for BaseRecord<'a, K, P, D> where
    K: Sync,
    P: Sync

impl<'a, K: ?Sized, P: ?Sized, D> Sync for BaseRecord<'a, K, P, D> where
    K: Sync,
    P: Sync

impl<'a, K: ?Sized, P: ?Sized, D> Unpin for BaseRecord<'a, K, P, D> where
    D: Unpin

impl<'a, K: ?Sized, P: ?Sized, D> UnwindSafe for BaseRecord<'a, K, P, D> where
    D: UnwindSafe,
    K: RefUnwindSafe,
    P: RefUnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.