soph_tracing/support/
instance.rs

1use crate::{
2    async_trait,
3    error::Error,
4    traits::{ErrorTrait, InstanceTrait},
5    Result, Tracing,
6};
7use soph_core::{
8    error::ContainerError,
9    support::{app, Container},
10};
11
12#[async_trait]
13impl InstanceTrait for Tracing {
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    fn cleanup() -> Result<(), ContainerError> {
24        let tracing = app().resolve::<Self>()?;
25        tracing.cleanup().map_err(Error::wrap)?;
26
27        Ok(())
28    }
29}