[−][src]Struct rdkafka::message::BorrowedMessage
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
BorrowedMessage
s 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 BorrowedMessage
s 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 key(&self) -> Option<&[u8]>
[src]
fn payload(&self) -> Option<&[u8]>
[src]
fn topic(&self) -> &str
[src]
fn partition(&self) -> i32
[src]
fn offset(&self) -> i64
[src]
fn timestamp(&self) -> Timestamp
[src]
fn headers(&self) -> Option<&BorrowedHeaders>
[src]
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]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,