aboutsummaryrefslogtreecommitdiff
path: root/macros/src/injectable/implementation.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-09-27 20:22:46 +0200
committerHampusM <hampus@hampusmat.com>2023-09-27 20:22:46 +0200
commit6533246020c9dcc1acfc02b1e5ed74fbbce4ea1f (patch)
tree5a852f3cd7816b46d9119362b42568d21f207bb5 /macros/src/injectable/implementation.rs
parent6a2c4025080776a386ab6dcd074fd05ae7319f9c (diff)
fix: set injectable macro dummies directly after parsing input
Diffstat (limited to 'macros/src/injectable/implementation.rs')
-rw-r--r--macros/src/injectable/implementation.rs69
1 files changed, 3 insertions, 66 deletions
diff --git a/macros/src/injectable/implementation.rs b/macros/src/injectable/implementation.rs
index 98e0abf..34c5437 100644
--- a/macros/src/injectable/implementation.rs
+++ b/macros/src/injectable/implementation.rs
@@ -1,10 +1,9 @@
use std::error::Error;
-use proc_macro2::{Ident, Span, TokenStream};
+use proc_macro2::{Ident, Span};
use quote::{format_ident, quote, ToTokens};
use syn::spanned::Spanned;
use syn::{
- parse2,
parse_str,
ExprMethodCall,
FnArg,
@@ -37,17 +36,11 @@ pub struct InjectableImpl<Dep: IDependency>
impl<Dep: IDependency> InjectableImpl<Dep>
{
#[cfg(not(tarpaulin_include))]
- pub fn parse(
- input: TokenStream,
+ pub fn new(
+ mut item_impl: ItemImpl,
constructor: &Ident,
) -> Result<Self, InjectableImplError>
{
- let mut item_impl = parse2::<ItemImpl>(input).map_err(|err| {
- InjectableImplError::NotAImplementation {
- err_span: err.span(),
- }
- })?;
-
if let Some((_, trait_path, _)) = item_impl.trait_ {
return Err(InjectableImplError::TraitImpl {
trait_path_span: trait_path.span(),
@@ -313,62 +306,6 @@ impl<Dep: IDependency> InjectableImpl<Dep>
}
}
- #[cfg(not(tarpaulin_include))]
- pub fn expand_dummy_blocking_impl(&self) -> proc_macro2::TokenStream
- {
- let generics = &self.generics;
- let self_type = &self.self_type;
-
- quote! {
- impl #generics syrette::interfaces::injectable::Injectable<
- syrette::di_container::blocking::DIContainer,
- > for #self_type
- {
- fn resolve(
- _: &syrette::di_container::blocking::DIContainer,
- _: syrette::dependency_history::DependencyHistory
- ) -> Result<
- syrette::ptr::TransientPtr<Self>,
- syrette::errors::injectable::InjectableError>
- {
- unimplemented!();
- }
- }
- }
- }
-
- #[cfg(not(tarpaulin_include))]
- pub fn expand_dummy_async_impl(&self) -> proc_macro2::TokenStream
- {
- let generics = &self.generics;
- let self_type = &self.self_type;
-
- quote! {
- impl #generics syrette::interfaces::async_injectable::AsyncInjectable<
- syrette::di_container::asynchronous::AsyncDIContainer,
- > for #self_type
- {
- fn resolve<'di_container, 'fut>(
- _: &'di_container
- syrette::di_container::asynchronous::AsyncDIContainer,
- _: syrette::dependency_history::DependencyHistory
- ) -> syrette::future::BoxFuture<
- 'fut,
- Result<
- syrette::ptr::TransientPtr<Self>,
- syrette::errors::injectable::InjectableError
- >
- >
- where
- Self: Sized + 'fut,
- 'di_container: 'fut
- {
- unimplemented!();
- }
- }
- }
- }
-
fn create_get_dep_method_calls(
dependencies: &[Dep],
is_async: bool,