Skip to main content

SendOptions

Struct SendOptions 

Source
#[non_exhaustive]
pub struct SendOptions { pub envelope: Option<Envelope>, pub transport_options: TransportOptions, pub timeout: Option<Duration>, pub idempotency_key: Option<IdempotencyKey>, pub correlation_id: Option<CorrelationId>, }
Expand description

Per-send controls shared by structured and raw transport sends.

With the serde feature enabled, this serializes as a sparse object: absent options are omitted, TransportOptions uses its provider-keyed representation, and timeout is encoded as { "secs": u64, "nanos": u32 }. Deserialization is intentionally registry-driven and not implemented on this type because provider-specific options need a TransportOptionRegistry; use TransportOptionRegistry::send_options_seed (or the convenience TransportOptionRegistry::deserialize_send_options wrapper) instead.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§envelope: Option<Envelope>

Optional custom SMTP envelope for structured crate::Transport sends.

This is only meaningful for structured transports that advertise crate::Capabilities::custom_envelope. Other structured transports may ignore it. crate::RawTransport methods take an explicit Envelope argument, and that argument is authoritative; raw transports ignore this field.

§transport_options: TransportOptions

Typed, in-process provider-specific controls.

With the serde feature enabled, TransportOptions serializes as a provider-keyed JSON object and can be hydrated through TransportOptionRegistry.

§timeout: Option<Duration>

Upper bound on provider-call duration for this send attempt. Transports advertising Capabilities::timeout must honor it; others should ignore it.

§idempotency_key: Option<IdempotencyKey>

Provider-level idempotency token for this attempt. Transports advertising Capabilities::idempotency_key must forward it; others should ignore it.

Validated at construction (rejects empty, NUL, CR/LF, non-tab control characters, and values longer than 1 KiB), see IdempotencyKey.

§correlation_id: Option<CorrelationId>

Opaque correlation identifier carried end-to-end from queue to transport. Built-in transports do not automatically expose it to providers; it is available to adapter-specific typed options when a provider has a natural slot for it.

Validated at construction with the same rules as IdempotencyKey, see CorrelationId.

Implementations§

Source§

impl SendOptions

Source

pub fn new() -> SendOptions

Create send options with no overrides.

Source

pub fn with_envelope(self, envelope: Envelope) -> SendOptions

Set the structured-send envelope override.

Source

pub fn with_transport_options( self, transport_options: TransportOptions, ) -> SendOptions

Replace the provider-specific typed option map.

Source

pub fn with_transport_option<T>(self, value: T) -> SendOptions

Insert or replace the provider option value of type T.

Slots are keyed by type, exactly like TransportOptions::insert. Unlike Self::with_transport_options, this keeps options of other types already present, so calls chain across providers.

Source

pub const fn with_timeout(self, timeout: Duration) -> SendOptions

Set the provider-call timeout for this attempt.

Source

pub fn with_idempotency_key( self, idempotency_key: IdempotencyKey, ) -> SendOptions

Set the provider idempotency key for this attempt.

Source

pub fn with_correlation_id(self, correlation_id: CorrelationId) -> SendOptions

Set the end-to-end tracing correlation identifier.

Source

pub fn serializable_without_idempotency_key(&self) -> impl Serialize

Return a serializable view that omits the provider idempotency key.

Queue adapters can use this when the idempotency key belongs to the queue invocation rather than the eventual provider request.

Trait Implementations§

Source§

impl Debug for SendOptions

Source§

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

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

impl Default for SendOptions

Source§

fn default() -> SendOptions

Returns the “default value” for a type. Read more
Source§

impl JsonSchema for SendOptions

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl Serialize for SendOptions

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

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MaybeSend for T
where T: Send + ?Sized,

Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> RuntimeBound for T
where T: Send + Sync + ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

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