pub struct Message { /* private fields */ }Implementations§
Source§impl Message
impl Message
Sourcepub fn builder() -> MessageBuilder
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();Sourcepub fn new(topic: impl Into<CheetahString>, body: &[u8]) -> Self
👎Deprecated since 0.8.0: Use Message::builder() instead
pub fn new(topic: impl Into<CheetahString>, body: &[u8]) -> Self
Use Message::builder() instead
Create a new message with topic and body slice (will copy)
Sourcepub fn new_with_bytes(topic: impl Into<CheetahString>, body: Bytes) -> Self
👎Deprecated since 0.8.0: Use Message::builder() instead
pub fn new_with_bytes(topic: impl Into<CheetahString>, body: Bytes) -> Self
Use Message::builder() instead
Create a new message with topic and Bytes (zero-copy)
Sourcepub fn new_with_vec(topic: impl Into<CheetahString>, body: Vec<u8>) -> Self
👎Deprecated since 0.8.0: Use Message::builder() instead
pub fn new_with_vec(topic: impl Into<CheetahString>, body: Vec<u8>) -> Self
Use Message::builder() instead
Create a new message with topic and Vec
pub fn new_body(topic: impl Into<CheetahString>, body: Option<Bytes>) -> Self
Use Message::builder() instead
👎Deprecated since 0.8.0: Use Message::builder() instead
Use Message::builder() instead
Create a message with tags and body slice (will copy)
👎Deprecated since 0.8.0: Use Message::builder() instead
Use Message::builder() instead
Create a message with tags and Bytes (zero-copy)
Sourcepub 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
pub fn with_keys( topic: impl Into<CheetahString>, tags: impl Into<CheetahString>, keys: impl Into<CheetahString>, body: &[u8], ) -> Self
Use Message::builder() instead
Create a message with keys and body slice (will copy)
Sourcepub 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
pub fn with_keys_bytes( topic: impl Into<CheetahString>, tags: impl Into<CheetahString>, keys: impl Into<CheetahString>, body: Bytes, ) -> Self
Use Message::builder() instead
Create a message with keys and Bytes (zero-copy)
Sourcepub 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
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
Use Message::builder() instead
Create message with body slice (will copy data)
Sourcepub 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
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
Use Message::builder() instead
Create message with Bytes (zero-copy)
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
pub fn set_keys(&mut self, keys: CheetahString)
pub fn clear_property(&mut self, name: impl Into<CheetahString>)
pub fn set_properties( &mut self, properties: HashMap<CheetahString, CheetahString>, )
pub fn get_property(&self, key: &CheetahString) -> Option<CheetahString>
pub fn body(&self) -> Option<Bytes>
pub fn flag(&self) -> i32
pub fn topic(&self) -> &CheetahString
pub fn properties(&self) -> &MessageProperties
pub fn transaction_id(&self) -> Option<&str>
pub fn get_transaction_id(&self) -> Option<&CheetahString>
pub fn is_wait_store_msg_ok(&self) -> bool
pub fn delay_time_level(&self) -> i32
pub fn set_delay_time_level(&mut self, level: i32)
pub fn get_user_property( &self, name: impl Into<CheetahString>, ) -> Option<CheetahString>
pub fn as_any(&self) -> &dyn Any
pub fn set_instance_id(&mut self, instance_id: impl Into<CheetahString>)
Sourcepub fn body_slice(&self) -> &[u8] ⓘ
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.
Sourcepub fn into_body(self) -> MessageBody
pub fn into_body(self) -> MessageBody
Consumes the message and returns the body.
Returns the message tags.
Sourcepub fn message_flag(&self) -> MessageFlag
pub fn message_flag(&self) -> MessageFlag
Returns the message flag as a type-safe MessageFlag.
Sourcepub fn wait_store_msg_ok(&self) -> bool
pub fn wait_store_msg_ok(&self) -> bool
Returns whether to wait for store confirmation.
Sourcepub fn delay_level(&self) -> i32
pub fn delay_level(&self) -> i32
Returns the delay time level.
Sourcepub fn instance_id(&self) -> Option<&str>
pub fn instance_id(&self) -> Option<&str>
Returns the instance ID.
Trait Implementations§
Source§impl MessageTrait for Message
impl MessageTrait for Message
Source§fn put_property(&mut self, key: CheetahString, value: CheetahString)
fn put_property(&mut self, key: CheetahString, value: CheetahString)
Source§fn clear_property(&mut self, name: &str)
fn clear_property(&mut self, name: &str)
Source§fn property(&self, name: &CheetahString) -> Option<CheetahString>
fn property(&self, name: &CheetahString) -> Option<CheetahString>
Source§fn property_ref(&self, name: &CheetahString) -> Option<&CheetahString>
fn property_ref(&self, name: &CheetahString) -> Option<&CheetahString>
Source§fn topic(&self) -> &CheetahString
fn topic(&self) -> &CheetahString
Source§fn set_topic(&mut self, topic: CheetahString)
fn set_topic(&mut self, topic: CheetahString)
Source§fn get_properties(&self) -> &HashMap<CheetahString, CheetahString>
fn get_properties(&self) -> &HashMap<CheetahString, CheetahString>
Source§fn set_properties(&mut self, properties: HashMap<CheetahString, CheetahString>)
fn set_properties(&mut self, properties: HashMap<CheetahString, CheetahString>)
Source§fn transaction_id(&self) -> Option<&CheetahString>
fn transaction_id(&self) -> Option<&CheetahString>
Source§fn set_transaction_id(&mut self, transaction_id: CheetahString)
fn set_transaction_id(&mut self, transaction_id: CheetahString)
Source§fn get_compressed_body_mut(&mut self) -> Option<&mut Bytes>
fn get_compressed_body_mut(&mut self) -> Option<&mut Bytes>
Source§fn get_compressed_body(&self) -> Option<&Bytes>
fn get_compressed_body(&self) -> Option<&Bytes>
Source§fn set_compressed_body_mut(&mut self, compressed_body: Bytes)
fn set_compressed_body_mut(&mut self, compressed_body: Bytes)
Source§fn take_body(&mut self) -> Option<Bytes>
fn take_body(&mut self) -> Option<Bytes>
Source§fn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Source§fn set_keys(&mut self, keys: CheetahString)
fn set_keys(&mut self, keys: CheetahString)
Source§fn put_user_property(
&mut self,
name: CheetahString,
value: CheetahString,
) -> RocketMQResult<()>
fn put_user_property( &mut self, name: CheetahString, value: CheetahString, ) -> RocketMQResult<()>
Source§fn user_property(&self, name: &CheetahString) -> Option<CheetahString>
fn user_property(&self, name: &CheetahString) -> Option<CheetahString>
Source§fn user_property_ref(&self, name: &CheetahString) -> Option<&CheetahString>
fn user_property_ref(&self, name: &CheetahString) -> Option<&CheetahString>
Source§fn get_keys(&self) -> Option<CheetahString>
fn get_keys(&self) -> Option<CheetahString>
Source§fn get_keys_ref(&self) -> Option<&CheetahString>
fn get_keys_ref(&self) -> Option<&CheetahString>
Source§fn set_keys_from_collection(&mut self, key_collection: Vec<String>)
fn set_keys_from_collection(&mut self, key_collection: Vec<String>)
Source§fn delay_time_level(&self) -> i32
fn delay_time_level(&self) -> i32
Source§fn set_delay_time_level(&mut self, level: i32)
fn set_delay_time_level(&mut self, level: i32)
Source§fn is_wait_store_msg_ok(&self) -> bool
fn is_wait_store_msg_ok(&self) -> bool
Source§fn 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)
Source§fn set_instance_id(&mut self, instance_id: CheetahString)
fn set_instance_id(&mut self, instance_id: CheetahString)
Source§fn buyer_id(&self) -> Option<CheetahString>
fn buyer_id(&self) -> Option<CheetahString>
Source§fn buyer_id_ref(&self) -> Option<&CheetahString>
fn buyer_id_ref(&self) -> Option<&CheetahString>
Source§fn set_buyer_id(&mut self, buyer_id: CheetahString)
fn set_buyer_id(&mut self, buyer_id: CheetahString)
Source§fn set_delay_time_sec(&mut self, sec: u64)
fn set_delay_time_sec(&mut self, sec: u64)
Source§fn get_delay_time_sec(&self) -> u64
fn get_delay_time_sec(&self) -> u64
Source§fn set_delay_time_ms(&mut self, time_ms: u64)
fn set_delay_time_ms(&mut self, time_ms: u64)
Source§fn get_delay_time_ms(&self) -> u64
fn get_delay_time_ms(&self) -> u64
Source§fn set_deliver_time_ms(&mut self, time_ms: u64)
fn set_deliver_time_ms(&mut self, time_ms: u64)
Source§fn get_deliver_time_ms(&self) -> u64
fn get_deliver_time_ms(&self) -> u64
Auto Trait Implementations§
impl !Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnsafeUnpin for Message
impl UnwindSafe for Message
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.