pub trait Mailable {
const TEMPLATE: &'static str;
// Provided methods
fn build(&self, base: Email) -> Email { ... }
fn context(&self) -> Context { ... }
fn render(&self, renderer: &EmailRenderer) -> Result<Email, MailableError> { ... }
fn send<'a>(
&'a self,
renderer: &'a EmailRenderer,
mailer: &'a BoxedMailer,
) -> Pin<Box<dyn Future<Output = Result<(), MailableError>> + Send + 'a>>
where Self: Sync { ... }
fn dispatch<'a, Q>(
&'a self,
renderer: &'a EmailRenderer,
queue: &'a Q,
) -> Pin<Box<dyn Future<Output = Result<(), MailableError>> + Send + 'a>>
where Self: Sync,
Q: JobQueue + Sync { ... }
}Expand description
One sendable email kind. The struct carries the per-email data, such as recipient, ids and URLs, and this trait ties it to a Tera template and to the addresses.
Required Associated Constants§
Provided Methods§
Sourcefn build(&self, base: Email) -> Email
fn build(&self, base: Email) -> Email
Set recipients, sender, reply-to and headers on the rendered
Email. The default returns it unchanged, so override this
and add at least one .to(...).
Sourcefn render(&self, renderer: &EmailRenderer) -> Result<Email, MailableError>
fn render(&self, renderer: &EmailRenderer) -> Result<Email, MailableError>
Render the email and return it ready to send.
§Errors
Render(_) when the template is missing or fails to render.
Sourcefn send<'a>(
&'a self,
renderer: &'a EmailRenderer,
mailer: &'a BoxedMailer,
) -> Pin<Box<dyn Future<Output = Result<(), MailableError>> + Send + 'a>>where
Self: Sync,
fn send<'a>(
&'a self,
renderer: &'a EmailRenderer,
mailer: &'a BoxedMailer,
) -> Pin<Box<dyn Future<Output = Result<(), MailableError>> + Send + 'a>>where
Self: Sync,
Render and send in the current request.
§Errors
Render(_) for template errors, Send(_) when the mailer
fails, for example a refused recipient or a transport error.
Sourcefn dispatch<'a, Q>(
&'a self,
renderer: &'a EmailRenderer,
queue: &'a Q,
) -> Pin<Box<dyn Future<Output = Result<(), MailableError>> + Send + 'a>>
fn dispatch<'a, Q>( &'a self, renderer: &'a EmailRenderer, queue: &'a Q, ) -> Pin<Box<dyn Future<Output = Result<(), MailableError>> + Send + 'a>>
Render now and put the email on the crate::jobs queue. This
returns at once; a worker delivers it.
§Errors
Render(_) for template errors. A queue error comes back as
Send(_) carrying the message text.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".