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§
Sourcefn put_property(&mut self, key: CheetahString, value: CheetahString)
fn put_property(&mut self, key: CheetahString, value: CheetahString)
Adds a property to the message.
§Arguments
key
- The property key, converted into aString
.value
- The property value, converted into aString
.
Sourcefn clear_property(&mut self, name: &str)
fn clear_property(&mut self, name: &str)
Sourcefn get_property(&self, name: &CheetahString) -> Option<CheetahString>
fn get_property(&self, name: &CheetahString) -> Option<CheetahString>
Sourcefn get_topic(&self) -> &CheetahString
fn get_topic(&self) -> &CheetahString
Sourcefn set_topic(&mut self, topic: CheetahString)
fn set_topic(&mut self, topic: CheetahString)
Sourcefn get_body(&self) -> Option<&Bytes>
fn get_body(&self) -> Option<&Bytes>
Retrieves the body of the message.
§Returns
A byte slice (&[u8]
) representing the body of the message.
Sourcefn get_properties(&self) -> &HashMap<CheetahString, CheetahString>
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.
Sourcefn set_properties(&mut self, properties: HashMap<CheetahString, CheetahString>)
fn set_properties(&mut self, properties: HashMap<CheetahString, CheetahString>)
Sets multiple properties for the message.
§Arguments
properties
- AHashMap<String, String>
containing the properties to set.
Sourcefn get_transaction_id(&self) -> Option<&CheetahString>
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
.
Sourcefn set_transaction_id(&mut self, transaction_id: CheetahString)
fn set_transaction_id(&mut self, transaction_id: CheetahString)
Sourcefn get_compressed_body_mut(&mut self) -> &mut Option<Bytes>
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.
Sourcefn get_compressed_body(&self) -> Option<&Bytes>
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.
Sourcefn set_compressed_body_mut(&mut self, compressed_body: Bytes)
fn set_compressed_body_mut(&mut self, compressed_body: Bytes)
Sets the compressed body of the message.
§Arguments
compressed_body
- ABytes
object representing the compressed body to set.
Sourcefn take_body(&mut self) -> Option<Bytes>
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
.
Sourcefn as_any_mut(&mut self) -> &mut dyn Any
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§
Sourcefn set_keys(&mut self, keys: CheetahString)
fn set_keys(&mut self, keys: CheetahString)
Sourcefn put_user_property(&mut self, name: CheetahString, value: CheetahString)
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 aString
.value
- The value of the user property, converted into aString
.
Sourcefn get_user_property(&self, name: &CheetahString) -> Option<CheetahString>
fn get_user_property(&self, name: &CheetahString) -> Option<CheetahString>
Retrieves the tags associated with the message.
§Returns
An Option<String>
containing the tags if they exist, otherwise None
.
Sourcefn get_keys(&self) -> Option<CheetahString>
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
.
Sourcefn set_keys_from_collection(&mut self, key_collection: Vec<String>)
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.
Sourcefn get_delay_time_level(&self) -> i32
fn get_delay_time_level(&self) -> i32
Sourcefn set_delay_time_level(&mut self, level: i32)
fn set_delay_time_level(&mut self, level: i32)
Sourcefn is_wait_store_msg_ok(&self) -> bool
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.
Sourcefn set_wait_store_msg_ok(&mut self, wait_store_msg_ok: bool)
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.
Sourcefn set_instance_id(&mut self, instance_id: CheetahString)
fn set_instance_id(&mut self, instance_id: CheetahString)
Sourcefn get_buyer_id(&self) -> Option<CheetahString>
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
.
Sourcefn set_buyer_id(&mut self, buyer_id: CheetahString)
fn set_buyer_id(&mut self, buyer_id: CheetahString)
Sourcefn set_delay_time_sec(&mut self, sec: u64)
fn set_delay_time_sec(&mut self, sec: u64)
Sourcefn get_delay_time_sec(&self) -> u64
fn get_delay_time_sec(&self) -> u64
Sourcefn set_delay_time_ms(&mut self, time_ms: u64)
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.
Sourcefn get_delay_time_ms(&self) -> u64
fn get_delay_time_ms(&self) -> u64
Sourcefn set_deliver_time_ms(&mut self, time_ms: u64)
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.
Sourcefn get_deliver_time_ms(&self) -> u64
fn get_deliver_time_ms(&self) -> u64
Retrieves the delivery time for the message in milliseconds.
§Returns
The delivery time in milliseconds.