Skip to main content

EnvelopeBuilder

Struct EnvelopeBuilder 

Source
pub struct EnvelopeBuilder<T> { /* private fields */ }
Expand description

Builds an Envelope<T>. Obtained from Envelope::builder.

Implementations§

Source§

impl<T: Message> EnvelopeBuilder<T>

Source

pub fn id(self, id: MessageId) -> Self

Overrides the generated id. Defaults to a fresh UUIDv7.

Source

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.

Source

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.

Source

pub fn correlation_id(self, id: CorrelationId) -> Self

Sets the business correlation id.

Source

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

Source

pub fn causation(self, parent: MessageId) -> Self

Records the message that caused this one.

Source

pub fn tenant(self, tenant_id: impl Into<String>) -> Self

Sets the owning tenant.

Source

pub fn expires_at(self, at: OffsetDateTime) -> Self

Sets the time after which the message SHALL NOT be published (§12.2).

Source

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

Source

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.

Source

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

Trait Implementations§

Source§

impl<T> Debug for EnvelopeBuilder<T>

Elides the body: an in-progress envelope’s body is arbitrary application data (§33).

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for EnvelopeBuilder<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for EnvelopeBuilder<T>
where T: RefUnwindSafe,

§

impl<T> Send for EnvelopeBuilder<T>
where T: Send,

§

impl<T> Sync for EnvelopeBuilder<T>
where T: Sync,

§

impl<T> Unpin for EnvelopeBuilder<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for EnvelopeBuilder<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for EnvelopeBuilder<T>
where T: UnwindSafe,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.