Struct rdkafka::message::BorrowedMessage [] [src]

pub struct BorrowedMessage<'a> { /* fields omitted */ }

A zero-copy Kafka message.

The content of the message is stored in the receiving buffer of the consumer or the producer. As such, BorrowedMessage cannot outlive the consumer or producer it belongs to.

Consumers

BorrowedMessages coming from consumers are removed from the consumer buffer once they are dropped. Holding references to too many messages will cause the memory of the consumer to fill up and the consumer to block until some of the BorrowedMessages are dropped.

Conversion to owned

To transform a BorrowedMessage into a OwnedMessage, use the detach method.

Methods

impl<'a> BorrowedMessage<'a>
[src]

[src]

Creates a new BorrowedMessage that wraps the native Kafka message pointer returned by a consumer. The lifetime of the message will be bound to the lifetime of the consumer passed as parameter. This method should only be used with messages coming from consumers. If the message contains an error, only the error is returned and the message structure is freed.

[src]

Creates a new BorrowedMessage that wraps the native Kafka message pointer returned by the delivery callback of a producer. The lifetime of the message will be bound to the lifetime of the reference passed as parameter. This method should only be used with messages coming from the delivery callback. The message will not be freed in any circumstance.

[src]

Returns a pointer to the RDKafkaMessage.

[src]

Returns a pointer to the message's RDKafkaTopic

[src]

Returns the length of the key field of the message.

[src]

Returns the length of the payload field of the message.

[src]

Clones the content of the BorrowedMessage and returns an OwnedMessage, that can outlive the consumer. This operation requires memory allocation and can be expensive.

Trait Implementations

impl<'a> Debug for BorrowedMessage<'a>
[src]

[src]

Formats the value using the given formatter.

impl<'a> Message for BorrowedMessage<'a>
[src]

[src]

Returns the key of the message, or None if there is no key.

[src]

Returns the payload of the message, or None if there is no payload.

[src]

Returns the source topic of the message.

[src]

Returns the partition number where the message is stored.

[src]

Returns the offset of the message.

[src]

Returns the message timestamp for a consumed message if available.

[src]

Converts the raw bytes of the payload to a reference of the specified type, that points to the same data inside the message and without performing any memory allocation Read more

[src]

Converts the raw bytes of the key to a reference of the specified type, that points to the same data inside the message and without performing any memory allocation Read more

impl<'a> Drop for BorrowedMessage<'a>
[src]

[src]

Executes the destructor for this type. Read more