Skip to main content

InboundMailSource

Trait InboundMailSource 

Source
pub trait InboundMailSource: Send + Sync {
    // Required methods
    fn kind(&self) -> &'static str;
    fn verifier(&self) -> WebhookVerifier;
    fn parse(
        &self,
        body: &[u8],
    ) -> Result<Option<InboundMessage>, InboundMailError>;
}
Expand description

A vendor’s inbound-mail webhook, implemented per vendor by adapter crates: how to verify a delivery’s signature and how to read a message out of the verified body. The inbound sibling of StatusWebhook and the mirror of Mailer — it hands a parsed InboundMessage to a module, where Mailer takes one from it.

Verification is not reimplemented here: verifier returns core’s WebhookVerifier, so constant-time compare, fail-closed on unreadable input and the replay tolerance are inherited, never re-derived. Resend signs with Svix (Svix); a provider whose delivery carries no HMAC — Postmark’s shared token — is a follow-up (ADR 0028).

Required Methods§

Source

fn kind(&self) -> &'static str

The vendor this source speaks for, for logs and metrics.

Source

fn verifier(&self) -> WebhookVerifier

The verifier deliveries must pass before parse is ever reached. Returned per call so an adapter may hold its config without holding a verifier — the secret is a parameter of receive_mail, never of the source.

Source

fn parse(&self, body: &[u8]) -> Result<Option<InboundMessage>, InboundMailError>

Reads one verified body. Ok(None) for a verified event that is not an inbound message (a delivery receipt, a ping).

§Errors

InboundMailError::Malformed when the verified body is not an event this vendor sends. Never InboundMailError::Signature — that answer belongs to receive_mail, before bytes are parsed.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§