pub struct MessageEnvelope {
pub id: Uuid,
pub sender: Uuid,
pub recipient: MessageTarget,
pub payload: Payload,
pub timestamp: DateTime<Utc>,
pub ttl: Option<u32>,
pub correlation_id: Option<Uuid>,
}Expand description
A message envelope that wraps any payload with routing metadata.
This is the universal message format used across all transports. Transports serialize/deserialize envelopes to their wire format.
Fields§
§id: UuidUnique message identifier.
sender: UuidThe sender’s agent identity UUID.
recipient: MessageTargetWho this message is addressed to.
payload: PayloadThe message payload.
timestamp: DateTime<Utc>When the message was created.
ttl: Option<u32>Optional time-to-live (number of hops before the message is dropped).
correlation_id: Option<Uuid>Optional correlation ID for request-response patterns.
Implementations§
Source§impl MessageEnvelope
impl MessageEnvelope
Sourcepub fn direct(
sender: Uuid,
recipient: Uuid,
payload: impl Into<Payload>,
) -> Self
pub fn direct( sender: Uuid, recipient: Uuid, payload: impl Into<Payload>, ) -> Self
Create a new envelope addressed to a specific agent.
Sourcepub fn broadcast(sender: Uuid, payload: impl Into<Payload>) -> Self
pub fn broadcast(sender: Uuid, payload: impl Into<Payload>) -> Self
Create a new broadcast envelope.
Sourcepub fn topic(
sender: Uuid,
topic: impl Into<String>,
payload: impl Into<Payload>,
) -> Self
pub fn topic( sender: Uuid, topic: impl Into<String>, payload: impl Into<Payload>, ) -> Self
Create a new topic-addressed envelope.
Sourcepub fn with_correlation(self, correlation_id: Uuid) -> Self
pub fn with_correlation(self, correlation_id: Uuid) -> Self
Set a correlation ID for request-response tracking.
Trait Implementations§
Source§impl Clone for MessageEnvelope
impl Clone for MessageEnvelope
Source§fn clone(&self) -> MessageEnvelope
fn clone(&self) -> MessageEnvelope
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 moreSource§impl Debug for MessageEnvelope
impl Debug for MessageEnvelope
Source§impl<'de> Deserialize<'de> for MessageEnvelope
impl<'de> Deserialize<'de> for MessageEnvelope
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for MessageEnvelope
impl RefUnwindSafe for MessageEnvelope
impl Send for MessageEnvelope
impl Sync for MessageEnvelope
impl Unpin for MessageEnvelope
impl UnsafeUnpin for MessageEnvelope
impl UnwindSafe for MessageEnvelope
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