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>,
pub trace_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.
trace_id: Option<Uuid>Optional trace ID for cross-system event correlation.
Set this to the same UUID used by the originating TaskAgent so that
network hops can be joined with audit log entries and A2A stream events.
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.
Sourcepub fn reply(&self, sender: Uuid, payload: impl Into<Payload>) -> Self
pub fn reply(&self, sender: Uuid, payload: impl Into<Payload>) -> Self
Create a reply envelope to this message.
The reply inherits the sender’s trace_id so the full
request-response exchange shares one trace.
Sourcepub fn with_trace(self, trace_id: Uuid) -> Self
pub fn with_trace(self, trace_id: Uuid) -> Self
Attach a trace ID to this envelope (builder pattern).
Trait Implementations§
Source§impl Clone for MessageEnvelope
impl Clone for MessageEnvelope
Source§fn clone(&self) -> MessageEnvelope
fn clone(&self) -> MessageEnvelope
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more