Struct rdkafka_wrap::message::BorrowedMessage
source · pub struct BorrowedMessage<'a> { /* private fields */ }Expand description
A zero-copy Kafka message.
Provides a read-only access to headers owned by a Kafka consumer or producer
or by an OwnedMessage struct.
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.
Implementations§
source§impl<'a> BorrowedMessage<'a>
impl<'a> BorrowedMessage<'a>
sourcepub fn ptr(&self) -> *mut rd_kafka_message_s
pub fn ptr(&self) -> *mut rd_kafka_message_s
Returns a pointer to the RDKafkaMessage.
sourcepub fn topic_ptr(&self) -> *mut rd_kafka_topic_s
pub fn topic_ptr(&self) -> *mut rd_kafka_topic_s
Returns a pointer to the message’s RDKafkaTopic
sourcepub fn payload_len(&self) -> usize
pub fn payload_len(&self) -> usize
Returns the length of the payload field of the message.
sourcepub fn detach(&self) -> OwnedMessage
pub fn detach(&self) -> OwnedMessage
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§
source§impl<'a> Debug for BorrowedMessage<'a>
impl<'a> Debug for BorrowedMessage<'a>
source§impl<'a> Message for BorrowedMessage<'a>
impl<'a> Message for BorrowedMessage<'a>
§type Headers = BorrowedHeaders
type Headers = BorrowedHeaders
source§fn payload(&self) -> Option<&[u8]>
fn payload(&self) -> Option<&[u8]>
None if there is no payload.source§unsafe fn payload_mut(&mut self) -> Option<&mut [u8]>
unsafe fn payload_mut(&mut self) -> Option<&mut [u8]>
None if
there is no payload. Read moresource§fn headers(&self) -> Option<&BorrowedHeaders>
fn headers(&self) -> Option<&BorrowedHeaders>
None if there are no headers.