From da7426ccb4aae87b322a884c31c6e5136c40927f Mon Sep 17 00:00:00 2001 From: HampusM Date: Sat, 16 Sep 2023 14:28:50 +0200 Subject: refactor!: remove async DI container interface BREAKING CHANGE: IAsyncDIContainer have been removed and multiple structs no longer take a DI container generic parameter --- src/test_utils.rs | 102 +++++------------------------------------------------- 1 file changed, 8 insertions(+), 94 deletions(-) (limited to 'src/test_utils.rs') diff --git a/src/test_utils.rs b/src/test_utils.rs index 95b7ce1..41e3753 100644 --- a/src/test_utils.rs +++ b/src/test_utils.rs @@ -144,7 +144,6 @@ pub mod subjects_async use async_trait::async_trait; use syrette_macros::declare_interface; - use crate::di_container::asynchronous::IAsyncDIContainer; use crate::interfaces::async_injectable::AsyncInjectable; use crate::ptr::TransientPtr; @@ -187,8 +186,6 @@ pub mod subjects_async #[async_trait] impl AsyncInjectable for UserManager - where - DIContainerType: IAsyncDIContainer, { async fn resolve( _: &Arc, @@ -254,8 +251,6 @@ pub mod subjects_async #[async_trait] impl AsyncInjectable for Number - where - DIContainerType: IAsyncDIContainer, { async fn resolve( _: &Arc, @@ -274,85 +269,6 @@ pub mod mocks #![allow(clippy::ref_option_ref)] // Caused by Mockall #![allow(dead_code)] // Not all mock functions may be used - #[cfg(feature = "async")] - pub mod async_di_container - { - use std::sync::Arc; - - use mockall::mock; - - use crate::di_container::asynchronous::binding::builder::AsyncBindingBuilder; - use crate::di_container::asynchronous::details::DIContainerInternals; - use crate::di_container::asynchronous::IAsyncDIContainer; - use crate::di_container::BindingOptions; - use crate::errors::async_di_container::AsyncDIContainerError; - use crate::provider::r#async::IAsyncProvider; - use crate::ptr::SomePtr; - use crate::util::use_double; - - use_double!(crate::dependency_history::DependencyHistory); - - mock! { - pub AsyncDIContainer {} - - #[async_trait::async_trait] - impl IAsyncDIContainer for AsyncDIContainer - { - fn bind(self: &mut Arc) -> - AsyncBindingBuilder - where - Interface: 'static + ?Sized + Send + Sync; - - async fn get( - self: &Arc, - ) -> Result, AsyncDIContainerError> - where - Interface: 'static + ?Sized + Send + Sync; - - async fn get_named( - self: &Arc, - name: &'static str, - ) -> Result, AsyncDIContainerError> - where - Interface: 'static + ?Sized + Send + Sync; - - #[doc(hidden)] - async fn get_bound( - self: &Arc, - dependency_history: DependencyHistory, - binding_options: BindingOptions<'static> - ) -> Result, AsyncDIContainerError> - where - Interface: 'static + ?Sized + Send + Sync; - } - - #[async_trait::async_trait] - impl DIContainerInternals for AsyncDIContainer - { - async fn has_binding( - self: &Arc, - binding_options: BindingOptions<'static>, - ) -> bool - where - Interface: ?Sized + 'static; - - async fn set_binding( - self: &Arc, - binding_options: BindingOptions<'static>, - provider: Box>, - ) where - Interface: 'static + ?Sized; - - async fn remove_binding( - self: &Arc, - binding_options: BindingOptions<'static>, - ) -> Option>> - where - Interface: 'static + ?Sized; - } - } - } - #[cfg(feature = "async")] pub mod async_provider { @@ -361,7 +277,6 @@ pub mod mocks use async_trait::async_trait; use mockall::mock; - use crate::di_container::asynchronous::IAsyncDIContainer; use crate::errors::injectable::InjectableError; use crate::provider::r#async::{AsyncProvidable, IAsyncProvider}; use crate::util::use_double; @@ -369,23 +284,22 @@ pub mod mocks use_double!(crate::dependency_history::DependencyHistory); mock! { - pub AsyncProvider {} + pub AsyncProvider {} #[async_trait] - impl< - DIContainerType: IAsyncDIContainer, - > IAsyncProvider for AsyncProvider< - DIContainerType, - > + impl IAsyncProvider + for AsyncProvider + where + DIContainerT: Send + Sync { async fn provide( &self, - di_container: &Arc, + di_container: &Arc, dependency_history: DependencyHistory - ) -> Result, InjectableError>; + ) -> Result, InjectableError>; fn do_clone(&self) -> - Box>; + Box>; } } } -- cgit v1.2.3-18-g5258