madsim_rdkafka::message

Struct 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.

Source

pub fn replace_headers(self, headers: Option<OwnedHeaders>) -> Self

Replaces the OwnedHeaders on this OwnedMessage.

Source

pub fn set_payload(self, payload: Option<Vec<u8>>) -> Self

Sets the payload for this OwnedMessage.

Source

pub fn set_key(self, key: Option<Vec<u8>>) -> Self

Sets the key for this OwnedMessage.

Source

pub fn set_topic(self, topic: String) -> Self

Sets the topic for this OwnedMessage.

Source

pub fn set_timestamp(self, timestamp: Timestamp) -> Self

Sets the timestamp for this OwnedMessage.

Source

pub fn set_partition(self, partition: i32) -> Self

Sets the partition for this OwnedMessage.

Source

pub fn set_offset(self, offset: i64) -> Self

Sets the offset for 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

Source§

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§

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

🔬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, 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,

Source§

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>,

Source§

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>,

Source§

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.