pub trait Message {
type Headers: Headers;
fn key(&self) -> Option<&[u8]>;
fn payload(&self) -> Option<&[u8]>;
unsafe fn payload_mut(&mut self) -> Option<&mut [u8]>;
fn topic(&self) -> &str;
fn partition(&self) -> i32;
fn offset(&self) -> i64;
fn timestamp(&self) -> Timestamp;
fn headers(&self) -> Option<&Self::Headers>;
fn payload_view<P: ?Sized + FromBytes>(
&self
) -> Option<Result<&P, P::Error>> { ... }
fn key_view<K: ?Sized + FromBytes>(&self) -> Option<Result<&K, K::Error>> { ... }
}
Expand description
A generic representation of a Kafka message.
Only read-only methods are provided by this trait, as the underlying storage might not allow modification.
Required Associated Types§
Required Methods§
sourcefn payload(&self) -> Option<&[u8]>
fn payload(&self) -> Option<&[u8]>
Returns the payload of the message, or None
if there is no payload.
sourceunsafe fn payload_mut(&mut self) -> Option<&mut [u8]>
unsafe fn payload_mut(&mut self) -> Option<&mut [u8]>
Returns a mutable reference to the payload of the message, or None
if
there is no payload.
Safety
librdkafka does not formally guarantee that modifying the payload is safe. Calling this method may therefore result in undefined behavior.