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

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]

pub fn ptr(&self) -> *mut RDKafkaMessage[src]

Returns a pointer to the RDKafkaMessage.

pub fn topic_ptr(&self) -> *mut RDKafkaTopic[src]

Returns a pointer to the message's RDKafkaTopic

pub fn key_len(&self) -> usize[src]

Returns the length of the key field of the message.

pub fn payload_len(&self) -> usize[src]

Returns the length of the payload field of the message.

pub fn detach(&self) -> OwnedMessage[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> Message for BorrowedMessage<'a>[src]

type Headers = BorrowedHeaders

Represent the type of headers that this message contains.

fn payload_view<P: ?Sized + FromBytes>(&self) -> Option<Result<&P, P::Error>>[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

fn key_view<K: ?Sized + FromBytes>(&self) -> Option<Result<&K, K::Error>>[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]

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

Auto Trait Implementations

impl<'a> !Send for BorrowedMessage<'a>

impl<'a> !Sync for BorrowedMessage<'a>

Blanket Implementations

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

impl<T> From for T[src]

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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