botx-api 0.1.6

Обертка над BotX api (eXpress)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::api::context::BotXApiContext;
use anthill_di::{types::AddDependencyResult, DependencyContext, LifeCycle, ServiceMappingBuilder};
use async_lock::RwLock;
use easy_ext::ext;

#[ext(IBotXApiContextExt)]
#[async_trait_with_sync::async_trait]
pub impl DependencyContext {
    async fn register_botx_api_context(
        &self,
    ) -> AddDependencyResult<ServiceMappingBuilder<RwLock<BotXApiContext>>> {
        self.register_type::<BotXApiContext>(LifeCycle::Transient)
            .await?;
        let ctx = self.resolve::<BotXApiContext>().await.unwrap();
        self.register_instance(RwLock::new(ctx)).await
    }
}