From c614b0f70b672265c3a2a790bb8fc92e09f6fd00 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sat, 1 Oct 2022 22:10:18 +0200 Subject: refactor: stop using the async_trait macro for AsyncInjectable --- macros/src/injectable/implementation.rs | 36 +++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'macros') diff --git a/macros/src/injectable/implementation.rs b/macros/src/injectable/implementation.rs index a84e798..82cbe16 100644 --- a/macros/src/injectable/implementation.rs +++ b/macros/src/injectable/implementation.rs @@ -87,27 +87,37 @@ impl InjectableImpl quote! { #maybe_doc_hidden - #[syrette::libs::async_trait::async_trait] impl #generics syrette::interfaces::async_injectable::AsyncInjectable for #self_type { - async fn resolve( - #di_container_var: &std::sync::Arc, + fn resolve<'di_container, 'fut>( + #di_container_var: &'di_container std::sync::Arc< + syrette::async_di_container::AsyncDIContainer + >, mut #dependency_history_var: Vec<&'static str>, - ) -> Result< - syrette::ptr::TransientPtr, - syrette::errors::injectable::InjectableError> + ) -> syrette::future::BoxFuture< + 'fut, + Result< + syrette::ptr::TransientPtr, + syrette::errors::injectable::InjectableError + > + > + where + Self: Sized + 'fut, + 'di_container: 'fut { - use std::any::type_name; + Box::pin(async move { + use std::any::type_name; - use syrette::errors::injectable::InjectableError; + use syrette::errors::injectable::InjectableError; - let self_type_name = type_name::<#self_type>(); + let self_type_name = type_name::<#self_type>(); - #maybe_prevent_circular_deps + #maybe_prevent_circular_deps - return Ok(syrette::ptr::TransientPtr::new(Self::new( - #(#async_get_dep_method_calls),* - ))); + Ok(syrette::ptr::TransientPtr::new(Self::new( + #(#async_get_dep_method_calls),* + ))) + }) } } -- cgit v1.2.3-18-g5258