pub struct Envelope {Show 19 fields
pub arcp: String,
pub id: MessageId,
pub timestamp: DateTime<Utc>,
pub source: Option<String>,
pub target: Option<String>,
pub session_id: Option<SessionId>,
pub job_id: Option<JobId>,
pub stream_id: Option<StreamId>,
pub subscription_id: Option<SubscriptionId>,
pub trace_id: Option<TraceId>,
pub span_id: Option<SpanId>,
pub parent_span_id: Option<SpanId>,
pub correlation_id: Option<MessageId>,
pub causation_id: Option<MessageId>,
pub idempotency_key: Option<IdempotencyKey>,
pub priority: Priority,
pub extensions: Option<Value>,
pub event_seq: Option<u64>,
pub payload: MessageType,
}Expand description
Typed protocol envelope (RFC §6.1).
payload is #[serde(flatten)]-embedded so the wire form is flat:
{
"arcp": "1.1", "id": "msg_...", "timestamp": "...",
"type": "ping", "payload": {}
}Fields§
§arcp: StringProtocol version understood by the sender.
id: MessageIdGlobally unique message id; transport-level idempotency key (RFC §6.4).
timestamp: DateTime<Utc>Sender timestamp in RFC 3339 format.
source: Option<String>Logical sender id (e.g. client / runtime / agent name).
target: Option<String>Logical recipient id.
session_id: Option<SessionId>Required once a session exists.
job_id: Option<JobId>Required for durable job events.
stream_id: Option<StreamId>Required for stream events.
subscription_id: Option<SubscriptionId>Required for subscription delivery.
trace_id: Option<TraceId>Stable id for one user-visible request or workflow (recommended).
span_id: Option<SpanId>Span id for the current operation (recommended).
parent_span_id: Option<SpanId>Parent span id when this message is part of a trace tree.
correlation_id: Option<MessageId>Id of the command or request this message answers.
causation_id: Option<MessageId>Id of the message that directly caused this message.
idempotency_key: Option<IdempotencyKey>Logical idempotency key for the command intent (RFC §6.4).
priority: PriorityMessage priority. Default normal.
extensions: Option<Value>Object of namespaced extension fields (RFC §21).
event_seq: Option<u64>Strictly increasing per-session sequence number for countable
events (ARCP v1.1 §6.5 / §6.6). Stamped by the runtime writer on
every envelope where MessageType::is_countable_event is true;
absent on session-control envelopes and on locally constructed
envelopes that have not yet been emitted by a runtime writer.
payload: MessageTypeType-specific body. Flattened so type and payload appear at the
envelope level on the wire.
Implementations§
Source§impl Envelope
impl Envelope
Sourcepub fn new(payload: MessageType) -> Envelope
pub fn new(payload: MessageType) -> Envelope
Construct a new envelope with the supplied payload, a freshly
generated MessageId, the current UTC timestamp, the crate’s
PROTOCOL_VERSION, and priority = normal.
Sourcepub fn into_raw(self) -> Result<RawEnvelope, ARCPError>
pub fn into_raw(self) -> Result<RawEnvelope, ARCPError>
Convert to the untyped wire shape suitable for inspection / logging without re-deserialising.
§Errors
Returns crate::error::ARCPError::Serialization if the envelope
cannot be serialised (this should not happen for any value
constructed by this crate).