From e8a2475b2f07da14c45a429b2b52e75322d0efb5 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 30 Jan 2023 22:25:02 +0100 Subject: fix: add missing dummy async injectable impl --- macros/src/injectable/implementation.rs | 37 +++++++++++++++++++++++++++++++++ macros/src/lib.rs | 6 +++++- 2 files changed, 42 insertions(+), 1 deletion(-) (limited to 'macros/src') diff --git a/macros/src/injectable/implementation.rs b/macros/src/injectable/implementation.rs index 0fd73de..e81dd2d 100644 --- a/macros/src/injectable/implementation.rs +++ b/macros/src/injectable/implementation.rs @@ -328,6 +328,43 @@ impl InjectableImpl } } + #[cfg(not(tarpaulin_include))] + pub fn expand_dummy_async_impl(&self) -> proc_macro2::TokenStream + { + let generics = &self.generics; + let self_type = &self.self_type; + + let di_container_var = format_ident!("{}", DI_CONTAINER_VAR_NAME); + let dependency_history_var = format_ident!("{}", DEPENDENCY_HISTORY_VAR_NAME); + + quote! { + impl #generics syrette::interfaces::async_injectable::AsyncInjectable< + syrette::di_container::asynchronous::AsyncDIContainer, + syrette::dependency_history::DependencyHistory + > for #self_type + { + fn resolve<'di_container, 'fut>( + #di_container_var: &'di_container std::sync::Arc< + syrette::di_container::asynchronous::AsyncDIContainer + >, + mut #dependency_history_var: syrette::dependency_history::DependencyHistory + ) -> syrette::future::BoxFuture< + 'fut, + Result< + syrette::ptr::TransientPtr, + syrette::errors::injectable::InjectableError + > + > + where + Self: Sized + 'fut, + 'di_container: 'fut + { + unimplemented!(); + } + } + } + } + fn create_get_dep_method_calls( dependencies: &[Dep], is_async: bool, diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 4c78204..04720c1 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -174,7 +174,11 @@ pub fn injectable(args_stream: TokenStream, input_stream: TokenStream) -> TokenS let injectable_impl = InjectableImpl::::parse(input_stream).unwrap_or_abort(); - set_dummy(injectable_impl.expand_dummy_blocking_impl()); + set_dummy(if is_async_flag.is_on() { + injectable_impl.expand_dummy_async_impl() + } else { + injectable_impl.expand_dummy_blocking_impl() + }); injectable_impl.validate().unwrap_or_abort(); -- cgit v1.2.3-18-g5258