pub struct EnvelopeBuilder<T> { /* private fields */ }Expand description
Builds an Envelope<T>. Obtained from Envelope::builder.
Implementations§
Source§impl<T: Message> EnvelopeBuilder<T>
impl<T: Message> EnvelopeBuilder<T>
Sourcepub fn metadata(self, metadata: Metadata) -> Self
pub fn metadata(self, metadata: Metadata) -> Self
Replaces the whole metadata struct, including its correlation metadata. Conversation
rooting is decided by value, not by call order: if the replacement’s conversation_id
is still crate::ConversationId::UNSET, Self::build roots it at the envelope’s own
id regardless of an earlier Self::conversation call; a non-UNSET value (including
one copied from a causing message) is kept.
Sourcepub fn correlation(self, correlation: CorrelationMetadata) -> Self
pub fn correlation(self, correlation: CorrelationMetadata) -> Self
Replaces the correlation metadata (correlation id, conversation id, causation, request
id) as a group. Same value-decides-rooting rule as Self::metadata.
Sourcepub fn correlation_id(self, id: CorrelationId) -> Self
pub fn correlation_id(self, id: CorrelationId) -> Self
Sets the business correlation id.
Sourcepub fn conversation(self, id: ConversationId) -> Self
pub fn conversation(self, id: ConversationId) -> Self
Joins an existing conversation — typically the causing message’s own conversation_id.
Self::build keeps this value as long as nothing later replaces it with
Self::metadata or Self::correlation (setter order matters only in that sense: the
last write to conversation_id wins, same as any other field).
Sourcepub fn expires_at(self, at: OffsetDateTime) -> Self
pub fn expires_at(self, at: OffsetDateTime) -> Self
Sets the time after which the message SHALL NOT be published (§12.2).
Sourcepub fn trace(
self,
traceparent: impl Into<String>,
tracestate: Option<String>,
) -> Self
pub fn trace( self, traceparent: impl Into<String>, tracestate: Option<String>, ) -> Self
Sets the W3C Trace Context to carry verbatim. Reliar never invents or re-derives it (ADR 0004, ADR 0020).
Sourcepub fn header(
self,
k: impl Into<String>,
v: impl Into<String>,
) -> Result<Self, HeaderError>
pub fn header( self, k: impl Into<String>, v: impl Into<String>, ) -> Result<Self, HeaderError>
Sets one custom header. Returns Err if k uses the reserved reliar- prefix or
breaches a cap (see Headers::insert).
§Errors
Returns HeaderError under the same conditions as Headers::insert.
Sourcepub fn build(self) -> Envelope<T>
pub fn build(self) -> Envelope<T>
Builds the envelope. message_type is MessageType::of::<T>(). conversation_id:
iff it is still crate::ConversationId::UNSET, it becomes this envelope’s own id
(an un-correlated message roots its own conversation); any other value — set via
Self::conversation, Self::correlation, or Self::metadata — is kept verbatim.
Rooting is decided by the value alone, never by which setter was called or in what order
(ADR 0011).