pub struct TransportMessage {
pub id: MessageId,
pub payload: Bytes,
pub metadata: TransportMessageMetadata,
}Expand description
A wrapper for a message being sent or received over a transport.
Fields§
§id: MessageIdThe unique identifier of the message.
payload: BytesThe binary payload of the message.
metadata: TransportMessageMetadataMetadata associated with the message.
Implementations§
Source§impl TransportMessage
impl TransportMessage
Sourcepub fn new(id: MessageId, payload: Bytes) -> Self
pub fn new(id: MessageId, payload: Bytes) -> Self
Creates a new TransportMessage with a given ID and payload.
§Example
let msg = TransportMessage::new(MessageId::from(1), Bytes::from("hello"));Sourcepub const fn with_metadata(
id: MessageId,
payload: Bytes,
metadata: TransportMessageMetadata,
) -> Self
pub const fn with_metadata( id: MessageId, payload: Bytes, metadata: TransportMessageMetadata, ) -> Self
Creates a new TransportMessage with the given ID, payload, and metadata.
Sourcepub const fn is_compressed(&self) -> bool
pub const fn is_compressed(&self) -> bool
Returns true if the message is compressed.
Sourcepub fn content_type(&self) -> Option<&str>
pub fn content_type(&self) -> Option<&str>
Returns the content type of the message, if specified.
Sourcepub fn correlation_id(&self) -> Option<&str>
pub fn correlation_id(&self) -> Option<&str>
Returns the correlation ID of the message, if specified.
Trait Implementations§
Source§impl Clone for TransportMessage
impl Clone for TransportMessage
Source§fn clone(&self) -> TransportMessage
fn clone(&self) -> TransportMessage
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !Freeze for TransportMessage
impl RefUnwindSafe for TransportMessage
impl Send for TransportMessage
impl Sync for TransportMessage
impl Unpin for TransportMessage
impl UnwindSafe for TransportMessage
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
Mutably borrows from an owned value. Read more