pub struct OwnedMessage { /* private fields */ }
Expand description

A Kafka message that owns its backing data.

An OwnedMessage can be created from a BorrowedMessage using the BorrowedMessage::detach method. OwnedMessages don’t hold any reference to the consumer and don’t use any memory inside the consumer buffer.

Implementations§

source§

impl OwnedMessage

source

pub fn new( payload: Option<Vec<u8, Global>>, key: Option<Vec<u8, Global>>, topic: String, timestamp: Timestamp, partition: i32, offset: i64, headers: Option<OwnedHeaders> ) -> OwnedMessage

Creates a new message with the specified content.

This function is mainly useful in tests of rust-rdkafka itself.

source

pub fn detach_headers(&mut self) -> Option<OwnedHeaders>

Detaches the OwnedHeaders from this OwnedMessage.

Trait Implementations§

source§

impl Clone for OwnedMessage

source§

fn clone(&self) -> OwnedMessage

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for OwnedMessage

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl Message for OwnedMessage

§

type Headers = OwnedHeaders

The type of headers that this message contains.
source§

fn key(&self) -> Option<&[u8]>

Returns the key of the message, or None if there is no key.
source§

fn payload(&self) -> Option<&[u8]>

Returns the payload of the message, or None if there is no payload.
source§

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. Read more
source§

fn topic(&self) -> &str

Returns the source topic of the message.
source§

fn partition(&self) -> i32

Returns the partition number where the message is stored.
source§

fn offset(&self) -> i64

Returns the offset of the message within the partition.
source§

fn timestamp(&self) -> Timestamp

Returns the message timestamp.
source§

fn headers(&self) -> Option<&OwnedHeaders>

Returns the headers of the message, or None if there are no headers.
source§

fn payload_view<P>(&self) -> Option<Result<&P, <P as FromBytes>::Error>>where P: FromBytes + ?Sized,

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.
source§

fn key_view<K>(&self) -> Option<Result<&K, <K as FromBytes>::Error>>where K: FromBytes + ?Sized,

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.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.