Skip to main content

Message

Struct Message 

Source
pub struct Message { /* private fields */ }

Implementations§

Source§

impl Message

Source

pub fn builder() -> MessageBuilder

Creates a new message builder.

This is the recommended way to create messages.

§Examples
use rocketmq_common::common::message::message_single::Message;

let msg = Message::builder()
    .topic("test-topic")
    .body_slice(b"hello world")
    .tags("important")
    .build_unchecked();
Source

pub fn new(topic: impl Into<CheetahString>, body: &[u8]) -> Self

👎Deprecated since 0.8.0:

Use Message::builder() instead

Create a new message with topic and body slice (will copy)

Source

pub fn new_with_bytes(topic: impl Into<CheetahString>, body: Bytes) -> Self

👎Deprecated since 0.8.0:

Use Message::builder() instead

Create a new message with topic and Bytes (zero-copy)

Source

pub fn new_with_vec(topic: impl Into<CheetahString>, body: Vec<u8>) -> Self

👎Deprecated since 0.8.0:

Use Message::builder() instead

Create a new message with topic and Vec (zero-copy conversion to Bytes)

Source

pub fn new_body(topic: impl Into<CheetahString>, body: Option<Bytes>) -> Self

👎Deprecated since 0.8.0:

Use Message::builder() instead

Source

pub fn with_tags( topic: impl Into<CheetahString>, tags: impl Into<CheetahString>, body: &[u8], ) -> Self

👎Deprecated since 0.8.0:

Use Message::builder() instead

Create a message with tags and body slice (will copy)

Source

pub fn with_tags_bytes( topic: impl Into<CheetahString>, tags: impl Into<CheetahString>, body: Bytes, ) -> Self

👎Deprecated since 0.8.0:

Use Message::builder() instead

Create a message with tags and Bytes (zero-copy)

Source

pub fn with_keys( topic: impl Into<CheetahString>, tags: impl Into<CheetahString>, keys: impl Into<CheetahString>, body: &[u8], ) -> Self

👎Deprecated since 0.8.0:

Use Message::builder() instead

Create a message with keys and body slice (will copy)

Source

pub fn with_keys_bytes( topic: impl Into<CheetahString>, tags: impl Into<CheetahString>, keys: impl Into<CheetahString>, body: Bytes, ) -> Self

👎Deprecated since 0.8.0:

Use Message::builder() instead

Create a message with keys and Bytes (zero-copy)

Source

pub fn with_details( topic: impl Into<CheetahString>, tags: impl Into<CheetahString>, keys: impl Into<CheetahString>, flag: i32, body: &[u8], wait_store_msg_ok: bool, ) -> Self

👎Deprecated since 0.8.0:

Use Message::builder() instead

Create message with body slice (will copy data)

Source

pub fn with_details_bytes( topic: impl Into<CheetahString>, tags: impl Into<CheetahString>, keys: impl Into<CheetahString>, flag: i32, body: Bytes, wait_store_msg_ok: bool, ) -> Self

👎Deprecated since 0.8.0:

Use Message::builder() instead

Create message with Bytes (zero-copy)

Source

pub fn with_details_body( topic: impl Into<CheetahString>, tags: impl Into<CheetahString>, keys: impl Into<CheetahString>, flag: i32, body: Option<Bytes>, wait_store_msg_ok: bool, ) -> Self

Source

pub fn set_tags(&mut self, tags: CheetahString)

Source

pub fn set_keys(&mut self, keys: CheetahString)

Source

pub fn clear_property(&mut self, name: impl Into<CheetahString>)

Source

pub fn set_properties( &mut self, properties: HashMap<CheetahString, CheetahString>, )

Source

pub fn get_property(&self, key: &CheetahString) -> Option<CheetahString>

Source

pub fn body(&self) -> Option<Bytes>

Source

pub fn flag(&self) -> i32

Source

pub fn topic(&self) -> &CheetahString

Source

pub fn properties(&self) -> &MessageProperties

Source

pub fn transaction_id(&self) -> Option<&str>

Source

pub fn get_transaction_id(&self) -> Option<&CheetahString>

Source

pub fn get_tags(&self) -> Option<CheetahString>

Source

pub fn is_wait_store_msg_ok(&self) -> bool

Source

pub fn delay_time_level(&self) -> i32

Source

pub fn set_delay_time_level(&mut self, level: i32)

Source

pub fn get_user_property( &self, name: impl Into<CheetahString>, ) -> Option<CheetahString>

Source

pub fn as_any(&self) -> &dyn Any

Source

pub fn set_instance_id(&mut self, instance_id: impl Into<CheetahString>)

Source

pub fn body_slice(&self) -> &[u8]

Returns the message body as a byte slice (borrows).

This is the recommended way to access the message body.

Source

pub fn into_body(self) -> MessageBody

Consumes the message and returns the body.

Source

pub fn tags(&self) -> Option<&str>

Returns the message tags.

Source

pub fn keys(&self) -> Option<Vec<String>>

Returns the message keys as a vector.

Source

pub fn property(&self, key: &str) -> Option<&str>

Returns a property value by key.

Source

pub fn message_flag(&self) -> MessageFlag

Returns the message flag as a type-safe MessageFlag.

Source

pub fn wait_store_msg_ok(&self) -> bool

Returns whether to wait for store confirmation.

Source

pub fn delay_level(&self) -> i32

Returns the delay time level.

Source

pub fn buyer_id(&self) -> Option<&str>

Returns the buyer ID.

Source

pub fn instance_id(&self) -> Option<&str>

Returns the instance ID.

Trait Implementations§

Source§

impl Clone for Message

Source§

fn clone(&self) -> Message

Returns a duplicate 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 Message

Source§

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

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

impl Default for Message

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for Message

Source§

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

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

impl MessageTrait for Message

Source§

fn put_property(&mut self, key: CheetahString, value: CheetahString)

Adds a property to the message.
Source§

fn clear_property(&mut self, name: &str)

Removes the specified property from the message.
Source§

fn property(&self, name: &CheetahString) -> Option<CheetahString>

Retrieves a property value.
Source§

fn property_ref(&self, name: &CheetahString) -> Option<&CheetahString>

Retrieves a reference to a property value.
Source§

fn topic(&self) -> &CheetahString

Returns the topic of the message.
Source§

fn set_topic(&mut self, topic: CheetahString)

Sets the topic for the message.
Source§

fn get_flag(&self) -> i32

Returns the flag associated with the message.
Source§

fn set_flag(&mut self, flag: i32)

Sets the flag for the message.
Source§

fn get_body(&self) -> Option<&Bytes>

Returns the body of the message.
Source§

fn set_body(&mut self, body: Bytes)

Sets the body of the message.
Source§

fn get_properties(&self) -> &HashMap<CheetahString, CheetahString>

Returns all properties associated with the message.
Source§

fn set_properties(&mut self, properties: HashMap<CheetahString, CheetahString>)

Sets multiple properties for the message.
Source§

fn transaction_id(&self) -> Option<&CheetahString>

Retrieves the transaction ID associated with the message. Read more
Source§

fn set_transaction_id(&mut self, transaction_id: CheetahString)

Sets the transaction ID for the message.
Source§

fn get_compressed_body_mut(&mut self) -> Option<&mut Bytes>

Returns a mutable reference to the compressed body of the message.
Source§

fn get_compressed_body(&self) -> Option<&Bytes>

Returns a reference to the compressed body of the message.
Source§

fn set_compressed_body_mut(&mut self, compressed_body: Bytes)

Sets the compressed body of the message.
Source§

fn take_body(&mut self) -> Option<Bytes>

Takes ownership of the message body, leaving it empty.
Source§

fn as_any(&self) -> &dyn Any

Returns a reference to the message as a trait object.
Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Returns a mutable reference to the message as a trait object.
Source§

fn set_keys(&mut self, keys: CheetahString)

Sets the keys for the message.
Source§

fn put_user_property( &mut self, name: CheetahString, value: CheetahString, ) -> RocketMQResult<()>

Adds a user-defined property to the message. Read more
Source§

fn user_property(&self, name: &CheetahString) -> Option<CheetahString>

Retrieves a user-defined property value.
Source§

fn user_property_ref(&self, name: &CheetahString) -> Option<&CheetahString>

Retrieves a reference to a user-defined property value.
Source§

fn tags(&self) -> Option<CheetahString>

Returns the tags associated with the message.
Source§

fn tags_ref(&self) -> Option<&CheetahString>

Returns a reference to the tags associated with the message.
Source§

fn set_tags(&mut self, tags: CheetahString)

Sets the tags for the message.
Source§

fn get_keys(&self) -> Option<CheetahString>

Returns the keys associated with the message.
Source§

fn get_keys_ref(&self) -> Option<&CheetahString>

Returns a reference to the keys associated with the message.
Source§

fn set_keys_from_collection(&mut self, key_collection: Vec<String>)

Sets the message keys from a collection, joining them with spaces.
Source§

fn delay_time_level(&self) -> i32

Returns the delay time level of the message, or 0 if not set.
Source§

fn set_delay_time_level(&mut self, level: i32)

Sets the delay time level for the message.
Source§

fn is_wait_store_msg_ok(&self) -> bool

Returns whether the message should wait for store acknowledgment. Read more
Source§

fn set_wait_store_msg_ok(&mut self, wait_store_msg_ok: bool)

Sets whether the message should wait for store acknowledgment.
Source§

fn set_instance_id(&mut self, instance_id: CheetahString)

Sets the instance ID for the message.
Source§

fn buyer_id(&self) -> Option<CheetahString>

Returns the buyer ID associated with the message.
Source§

fn buyer_id_ref(&self) -> Option<&CheetahString>

Returns a reference to the buyer ID associated with the message.
Source§

fn set_buyer_id(&mut self, buyer_id: CheetahString)

Sets the buyer ID for the message.
Source§

fn set_delay_time_sec(&mut self, sec: u64)

Sets the delay time for the message in seconds.
Source§

fn get_delay_time_sec(&self) -> u64

Returns the delay time for the message in seconds, or 0 if not set.
Source§

fn set_delay_time_ms(&mut self, time_ms: u64)

Sets the delay time for the message in milliseconds.
Source§

fn get_delay_time_ms(&self) -> u64

Returns the delay time for the message in milliseconds, or 0 if not set.
Source§

fn set_deliver_time_ms(&mut self, time_ms: u64)

Sets the delivery time for the message in milliseconds.
Source§

fn get_deliver_time_ms(&self) -> u64

Returns the delivery time for the message in milliseconds, or 0 if not set.

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, dest: *mut u8)

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

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