Skip to main content

Envelope

Struct Envelope 

Source
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: String

Protocol version understood by the sender.

§id: MessageId

Globally 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: Priority

Message 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: MessageType

Type-specific body. Flattened so type and payload appear at the envelope level on the wire.

Implementations§

Source§

impl Envelope

Source

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.

Source

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).

Trait Implementations§

Source§

impl Clone for Envelope

Source§

fn clone(&self) -> Envelope

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Envelope

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Envelope

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Envelope, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Envelope

Source§

fn eq(&self, other: &Envelope) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Envelope

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Envelope

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,