#[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
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: TransportOptionsTyped, 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
impl SendOptions
Sourcepub fn new() -> SendOptions
pub fn new() -> SendOptions
Create send options with no overrides.
Sourcepub fn with_envelope(self, envelope: Envelope) -> SendOptions
pub fn with_envelope(self, envelope: Envelope) -> SendOptions
Set the structured-send envelope override.
Sourcepub fn with_transport_options(
self,
transport_options: TransportOptions,
) -> SendOptions
pub fn with_transport_options( self, transport_options: TransportOptions, ) -> SendOptions
Replace the provider-specific typed option map.
Sourcepub fn with_transport_option<T>(self, value: T) -> SendOptionswhere
T: TransportOption + Serialize,
pub fn with_transport_option<T>(self, value: T) -> SendOptionswhere
T: TransportOption + Serialize,
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.
Sourcepub const fn with_timeout(self, timeout: Duration) -> SendOptions
pub const fn with_timeout(self, timeout: Duration) -> SendOptions
Set the provider-call timeout for this attempt.
Sourcepub fn with_idempotency_key(
self,
idempotency_key: IdempotencyKey,
) -> SendOptions
pub fn with_idempotency_key( self, idempotency_key: IdempotencyKey, ) -> SendOptions
Set the provider idempotency key for this attempt.
Sourcepub fn with_correlation_id(self, correlation_id: CorrelationId) -> SendOptions
pub fn with_correlation_id(self, correlation_id: CorrelationId) -> SendOptions
Set the end-to-end tracing correlation identifier.
Sourcepub fn serializable_without_idempotency_key(&self) -> impl Serialize
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
impl Debug for SendOptions
Source§impl Default for SendOptions
impl Default for SendOptions
Source§fn default() -> SendOptions
fn default() -> SendOptions
Source§impl JsonSchema for SendOptions
impl JsonSchema for SendOptions
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl Serialize for SendOptions
impl Serialize for SendOptions
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl !RefUnwindSafe for SendOptions
impl !UnwindSafe for SendOptions
impl Freeze for SendOptions
impl Send for SendOptions
impl Sync for SendOptions
impl Unpin for SendOptions
impl UnsafeUnpin for SendOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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