Struct rdkafka::message::OwnedMessage

source ·
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>>, key: Option<Vec<u8>>, 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

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

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.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where 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 T
where 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 T
where 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 T
where 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.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more