soph_database/support/
instance.rsuse crate::{
async_trait,
error::Error,
traits::{ErrorTrait, InstanceTrait},
Database, Result,
};
use soph_core::{
error::ContainerError,
support::{app, Container},
};
#[async_trait]
impl InstanceTrait for Database {
type Error = Error;
async fn register(_: &Container) -> Result<Self, ContainerError>
where
Self: Sized,
{
Ok(Self::new().await.map_err(Error::wrap)?)
}
async fn boot() -> Result<(), ContainerError>
where
Self: Sized,
{
let database = app().resolve::<Self>()?;
database.ping().await.map_err(Error::wrap)?;
Ok(())
}
}