soph_mail/support/
instance.rs

1use crate::{
2    async_trait,
3    traits::{ErrorTrait, InstanceTrait},
4    Mail, Result,
5};
6use soph_config::error::Error;
7use soph_core::{
8    error::ContainerError,
9    support::{app, Container},
10};
11
12#[async_trait]
13impl InstanceTrait for Mail {
14    type Error = Error;
15
16    async fn register(_: &Container) -> Result<Self, ContainerError>
17    where
18        Self: Sized,
19    {
20        Ok(Self::new().map_err(Error::wrap)?)
21    }
22
23    async fn boot() -> Result<(), ContainerError>
24    where
25        Self: Sized,
26    {
27        let mail = app().resolve::<Self>()?;
28
29        mail.test_connection().await.map_err(Error::wrap)?;
30
31        Ok(())
32    }
33}