Trait MessageTrait

Source
pub trait MessageTrait:
    Any
    + Display
    + Debug {
Show 39 methods // Required methods fn put_property(&mut self, key: CheetahString, value: CheetahString); fn clear_property(&mut self, name: &str); fn get_property(&self, name: &CheetahString) -> Option<CheetahString>; fn get_topic(&self) -> &CheetahString; fn set_topic(&mut self, topic: CheetahString); fn get_flag(&self) -> i32; fn set_flag(&mut self, flag: i32); fn get_body(&self) -> Option<&Bytes>; fn set_body(&mut self, body: Bytes); fn get_properties(&self) -> &HashMap<CheetahString, CheetahString>; fn set_properties( &mut self, properties: HashMap<CheetahString, CheetahString>, ); fn get_transaction_id(&self) -> Option<&CheetahString>; fn set_transaction_id(&mut self, transaction_id: CheetahString); fn get_compressed_body_mut(&mut self) -> &mut Option<Bytes>; fn get_compressed_body(&self) -> Option<&Bytes>; fn set_compressed_body_mut(&mut self, compressed_body: Bytes); fn take_body(&mut self) -> Option<Bytes>; fn as_any(&self) -> &dyn Any; fn as_any_mut(&mut self) -> &mut dyn Any; // Provided methods fn set_keys(&mut self, keys: CheetahString) { ... } fn put_user_property(&mut self, name: CheetahString, value: CheetahString) { ... } fn get_user_property(&self, name: &CheetahString) -> Option<CheetahString> { ... } fn get_tags(&self) -> Option<CheetahString> { ... } fn set_tags(&mut self, tags: CheetahString) { ... } fn get_keys(&self) -> Option<CheetahString> { ... } fn set_keys_from_collection(&mut self, key_collection: Vec<String>) { ... } fn get_delay_time_level(&self) -> i32 { ... } fn set_delay_time_level(&mut self, level: i32) { ... } fn is_wait_store_msg_ok(&self) -> bool { ... } fn set_wait_store_msg_ok(&mut self, wait_store_msg_ok: bool) { ... } fn set_instance_id(&mut self, instance_id: CheetahString) { ... } fn get_buyer_id(&self) -> Option<CheetahString> { ... } fn set_buyer_id(&mut self, buyer_id: CheetahString) { ... } fn set_delay_time_sec(&mut self, sec: u64) { ... } fn get_delay_time_sec(&self) -> u64 { ... } fn set_delay_time_ms(&mut self, time_ms: u64) { ... } fn get_delay_time_ms(&self) -> u64 { ... } fn set_deliver_time_ms(&mut self, time_ms: u64) { ... } fn get_deliver_time_ms(&self) -> u64 { ... }
}
Expand description

This module defines the MessageTrait trait, which provides a flexible interface for working

with message objects in RocketMQ. It includes methods for managing message properties, keys, tags, body, and other metadata related to the message.

Required Methods§

Source

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

Adds a property to the message.

§Arguments
  • key - The property key, converted into a String.
  • value - The property value, converted into a String.
Source

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

Clears a specific property from the message.

§Arguments
  • name - The name of the property to clear.
Source

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

Retrieves a property from the message.

§Arguments
  • name - The name of the property to retrieve.
§Returns

An Option<String> containing the property value if it exists, otherwise None.

Source

fn get_topic(&self) -> &CheetahString

Retrieves the topic of the message.

§Returns

A reference to the topic as a &str.

Source

fn set_topic(&mut self, topic: CheetahString)

Sets the topic for the message.

§Arguments
  • topic - The topic to set, converted into a String.
Source

fn get_flag(&self) -> i32

Retrieves the flag associated with the message.

§Returns

An i32 representing the flag.

Source

fn set_flag(&mut self, flag: i32)

Sets the flag for the message.

§Arguments
  • flag - The flag to set.
Source

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

Retrieves the body of the message.

§Returns

A byte slice (&[u8]) representing the body of the message.

Source

fn set_body(&mut self, body: Bytes)

Sets the body of the message.

§Arguments
  • body - The byte slice (&[u8]) to set as the body.
Source

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

Retrieves all properties associated with the message.

§Returns

A reference to a HashMap<String, String> containing the properties.

Source

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

Sets multiple properties for the message.

§Arguments
  • properties - A HashMap<String, String> containing the properties to set.
Source

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

Retrieves the transaction ID associated with the message.

§Returns

A reference to the transaction ID as a &str.

Source

fn set_transaction_id(&mut self, transaction_id: CheetahString)

Sets the transaction ID for the message.

§Arguments
  • transaction_id - The transaction ID to set.
Source

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

Retrieves a mutable reference to the compressed body of the message.

§Returns

A mutable reference to an Option<Bytes> containing the compressed body, if it exists.

Source

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

Retrieves an immutable reference to the compressed body of the message.

§Returns

An Option<&Bytes> containing the compressed body, if it exists.

Source

fn set_compressed_body_mut(&mut self, compressed_body: Bytes)

Sets the compressed body of the message.

§Arguments
  • compressed_body - A Bytes object representing the compressed body to set.
Source

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

Takes ownership of the message body, leaving it empty.

§Returns

An Option<Bytes> containing the message body if it exists, otherwise None.

Source

fn as_any(&self) -> &dyn Any

Converts the message into a dynamic Any type.

§Returns

A reference to the message as &dyn Any.

Source

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

Converts the message into a mutable dynamic Any type.

§Returns

A mutable reference to the message as &mut dyn Any.

Provided Methods§

Source

fn set_keys(&mut self, keys: CheetahString)

Sets the keys for the message.

§Arguments
  • keys - The keys to set, converted into a String.
Source

fn put_user_property(&mut self, name: CheetahString, value: CheetahString)

Adds a user-defined property to the message.

§Arguments
  • name - The name of the user property, converted into a String.
  • value - The value of the user property, converted into a String.
Source

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

Retrieves a user-defined property from the message.

§Arguments
  • name - The name of the user property to retrieve.
§Returns

An Option<String> containing the property value if it exists, otherwise None.

Source

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

Retrieves the tags associated with the message.

§Returns

An Option<String> containing the tags if they exist, otherwise None.

Source

fn set_tags(&mut self, tags: CheetahString)

Sets the tags for the message.

§Arguments
  • tags - The tags to set, converted into a String.
Source

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

Retrieves the keys associated with the message.

§Returns

An Option<String> containing the keys if they exist, otherwise None.

Source

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

Sets multiple keys from a collection for the message.

§Arguments
  • key_collection - A vector of keys to set.
Source

fn get_delay_time_level(&self) -> i32

Retrieves the delay time level of the message.

§Returns

An i32 representing the delay time level.

Source

fn set_delay_time_level(&mut self, level: i32)

Sets the delay time level for the message.

§Arguments
  • level - The delay time level to set.
Source

fn is_wait_store_msg_ok(&self) -> bool

Checks if the message should wait for store acknowledgment.

§Returns

true if the message should wait for store acknowledgment; false otherwise.

Source

fn set_wait_store_msg_ok(&mut self, wait_store_msg_ok: bool)

Sets whether the message should wait for store acknowledgment.

§Arguments
  • wait_store_msg_ok - A boolean indicating whether to wait for store acknowledgment.
Source

fn set_instance_id(&mut self, instance_id: CheetahString)

Sets the instance ID for the message.

§Arguments
  • instance_id - The instance ID to set.
Source

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

Retrieves the buyer ID associated with the message.

§Returns

An Option<String> containing the buyer ID if it exists, otherwise None.

Source

fn set_buyer_id(&mut self, buyer_id: CheetahString)

Sets the buyer ID for the message.

§Arguments
  • buyer_id - The buyer ID to set.
Source

fn set_delay_time_sec(&mut self, sec: u64)

Sets the delay time for the message in seconds.

§Arguments
  • sec - The delay time in seconds.
Source

fn get_delay_time_sec(&self) -> u64

Retrieves the delay time for the message in seconds.

§Returns

The delay time in seconds.

Source

fn set_delay_time_ms(&mut self, time_ms: u64)

Sets the delay time for the message in milliseconds.

§Arguments
  • time_ms - The delay time in milliseconds.
Source

fn get_delay_time_ms(&self) -> u64

Retrieves the delay time for the message in milliseconds.

§Returns

The delay time in milliseconds.

Source

fn set_deliver_time_ms(&mut self, time_ms: u64)

Sets the delivery time for the message in milliseconds.

§Arguments
  • time_ms - The delivery time in milliseconds.
Source

fn get_deliver_time_ms(&self) -> u64

Retrieves the delivery time for the message in milliseconds.

§Returns

The delivery time in milliseconds.

Implementors§