soph-redis 0.28.2

The RUST Framework for Web Rustceans.
Documentation
use crate::{
    async_trait,
    error::Error,
    traits::{ErrorTrait, InstanceTrait},
    Redis, Result,
};
use soph_core::{
    error::ContainerError,
    support::{app, Container},
};

#[async_trait]
impl InstanceTrait for Redis {
    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 redis = app().resolve::<Self>()?;

        redis.ping().await.map_err(Error::wrap)?;

        Ok(())
    }
}