Struct rdkafka::message::BorrowedMessage [−][src]
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
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.
Implementations
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> Debug for BorrowedMessage<'a>
[src]
impl<'a> Message for BorrowedMessage<'a>
[src]
type Headers = BorrowedHeaders
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]
fn key_view<K: ?Sized + FromBytes>(&self) -> Option<Result<&K, K::Error>>
[src]
impl<'a> Send for BorrowedMessage<'a>
[src]
impl<'a> Sync for BorrowedMessage<'a>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for BorrowedMessage<'a>
impl<'a> Unpin for BorrowedMessage<'a>
impl<'a> UnwindSafe for BorrowedMessage<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,