ayun-redis 0.24.0

The RUST Framework for Web Rustceans.
use crate::{config, error::Error, Redis};
use ayun_config::traits::ConfigurationTrait;
use ayun_core::{
    error::ContainerError,
    support::{app, Container},
    traits::{ErrorTrait, InstanceTrait},
    Result,
};
use ayun_runtime::Runtime;

impl InstanceTrait for Redis {
    fn register(container: &Container) -> Result<Self, ContainerError>
    where
        Self: Sized,
    {
        let config = container
            .resolve::<ayun_config::Config>()?
            .get::<config::Redis>("redis")
            .map_err(Error::wrap)?;

        Ok(container
            .resolve::<Runtime>()?
            .block_on(Self::try_from_config(config))
            .map_err(Error::wrap)?)
    }

    fn boot() -> Result<(), ContainerError>
    where
        Self: Sized,
    {
        let redis = app().resolve::<Self>()?;

        app()
            .resolve::<Runtime>()?
            .block_on(redis.ping())
            .map_err(Error::wrap)?;

        Ok(())
    }
}