Struct rdkafka::message::BorrowedMessage
[−]
[src]
pub struct BorrowedMessage<'a> { /* fields omitted */ }
A native librdkafka message. The content of the message is stored in the receiving buffer of
the consumer, to avoid memory allocations. As such, BorrowedMessage
cannot outlive the
consumer it is received from.
BorrowedMessage
s are removed from the consumer buffer once they are dropped. Holding
references to many messages might cause the memory of the consumer to fill up and stop.
To transform a BorrowedMessage
into a OwnedMessage
, use the detach
method.
Methods
impl<'a> BorrowedMessage<'a>
[src]
fn new<C, X>(ptr: *mut RDKafkaMessage, _consumer: &'a C) -> BorrowedMessage<'a> where
X: ConsumerContext,
C: Consumer<X>,
X: ConsumerContext,
C: Consumer<X>,
Creates a new BorrowedMessage
that wraps the native Kafka message pointer. The lifetime of the
message will be bound to the lifetime of the consumer passed as parameter.
fn ptr(&self) -> *mut RDKafkaMessage
Returns a pointer to the RDKafkaMessage.
fn topic_ptr(&self) -> *mut RDKafkaTopic
Returns a pointer to the message's RDKafkaTopic
fn key_len(&self) -> usize
Returns the length of the key field of the message.
fn payload_len(&self) -> usize
Returns the length of the payload field of the message.
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
impl<'a> Debug for BorrowedMessage<'a>
[src]
impl<'a> Message for BorrowedMessage<'a>
[src]
fn key(&self) -> Option<&[u8]>
Returns the key of the message, or None if there is no key.
fn payload(&self) -> Option<&[u8]>
Returns the payload of the message, or None if there is no payload.
fn topic(&self) -> &str
Returns the source topic of the message.
fn partition(&self) -> i32
Returns the partition number where the message is stored.
fn offset(&self) -> i64
Returns the offset of the message.
fn timestamp(&self) -> Timestamp
Returns the message timestamp for a consumed message if available.
fn payload_view<P: ?Sized + FromBytes>(&self) -> Option<Result<&P, P::Error>>
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>>
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