diff options
author | HampusM <hampus@hampusmat.com> | 2022-10-01 22:10:18 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-10-01 22:10:18 +0200 |
commit | c614b0f70b672265c3a2a790bb8fc92e09f6fd00 (patch) | |
tree | 3c8b0eb5509b07d3210bb70bd2cbd6215ec9516c /macros | |
parent | 344dff10f8ac2e176239e10190bdb627bf58156b (diff) |
refactor: stop using the async_trait macro for AsyncInjectable
Diffstat (limited to 'macros')
-rw-r--r-- | macros/src/injectable/implementation.rs | 36 |
1 files changed, 23 insertions, 13 deletions
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<syrette::async_di_container::AsyncDIContainer>, + 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<Self>, - syrette::errors::injectable::InjectableError> + ) -> syrette::future::BoxFuture< + 'fut, + Result< + syrette::ptr::TransientPtr<Self>, + 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),* + ))) + }) } } |