From 9bed6b4d2772fd020ea9eb6eaaba4ca014d96f94 Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 14 Sep 2023 19:41:56 +0200 Subject: refactor!: remove blocking DI container interface BREAKING CHANGE: IDIContainer have been removed and multiple structs no longer take a DI container generic parameter --- src/test_utils.rs | 124 +++--------------------------------------------------- 1 file changed, 7 insertions(+), 117 deletions(-) (limited to 'src/test_utils.rs') diff --git a/src/test_utils.rs b/src/test_utils.rs index a304a71..95b7ce1 100644 --- a/src/test_utils.rs +++ b/src/test_utils.rs @@ -7,7 +7,6 @@ pub mod subjects use syrette_macros::declare_interface; - use crate::di_container::blocking::IDIContainer; use crate::interfaces::injectable::Injectable; use crate::private::cast::CastFromArc; use crate::ptr::TransientPtr; @@ -49,12 +48,10 @@ pub mod subjects declare_interface!(UserManager -> IUserManager); - impl Injectable for UserManager - where - DIContainerType: IDIContainer, + impl Injectable for UserManager { fn resolve( - _di_container: &Rc, + _di_container: &Rc, _dependency_history: DependencyHistory, ) -> Result, crate::errors::injectable::InjectableError> where @@ -115,12 +112,10 @@ pub mod subjects declare_interface!(Number -> INumber); - impl Injectable for Number - where - DIContainerType: IDIContainer, + impl Injectable for Number { fn resolve( - _di_container: &Rc, + _di_container: &Rc, _dependency_history: DependencyHistory, ) -> Result, crate::errors::injectable::InjectableError> where @@ -279,87 +274,13 @@ pub mod mocks #![allow(clippy::ref_option_ref)] // Caused by Mockall #![allow(dead_code)] // Not all mock functions may be used - use mockall::mock; - - pub mod blocking_di_container - { - use std::rc::Rc; - - use super::*; - use crate::di_container::blocking::binding::builder::BindingBuilder; - use crate::di_container::blocking::details::DIContainerInternals; - use crate::di_container::blocking::{BindingOptionsWithLt, IDIContainer}; - use crate::di_container::BindingOptions; - use crate::errors::di_container::DIContainerError; - use crate::provider::blocking::IProvider; - use crate::ptr::SomePtr; - use crate::util::use_double; - - use_double!(crate::dependency_history::DependencyHistory); - - mock! { - pub DIContainer {} - - impl IDIContainer for DIContainer - { - fn bind(self: &mut Rc) -> BindingBuilder - where - Interface: 'static + ?Sized; - - fn get(self: &Rc) -> Result, DIContainerError> - where - Interface: 'static + ?Sized; - - fn get_named( - self: &Rc, - name: &'static str, - ) -> Result, DIContainerError> - where - Interface: 'static + ?Sized; - - #[doc(hidden)] - fn get_bound<'opts, Interface>( - self: &Rc, - dependency_history: DependencyHistory, - binding_options: BindingOptionsWithLt, - ) -> Result, DIContainerError> - where - Interface: 'static + ?Sized; - } - - impl DIContainerInternals for DIContainer - { - fn has_binding( - self: &Rc, - binding_options: BindingOptionsWithLt - ) -> bool - where - Interface: ?Sized + 'static; - - #[doc(hidden)] - fn set_binding( - self: &Rc, - binding_options: BindingOptions<'static>, - provider: Box>, - ) where - Interface: 'static + ?Sized; - - fn remove_binding( - self: &Rc, - binding_options: BindingOptions<'static>, - ) -> Option>> - where - Interface: 'static + ?Sized; - } - } - } - #[cfg(feature = "async")] pub mod async_di_container { use std::sync::Arc; - use super::*; + use mockall::mock; + use crate::di_container::asynchronous::binding::builder::AsyncBindingBuilder; use crate::di_container::asynchronous::details::DIContainerInternals; use crate::di_container::asynchronous::IAsyncDIContainer; @@ -438,8 +359,8 @@ pub mod mocks use std::sync::Arc; use async_trait::async_trait; + use mockall::mock; - use super::*; use crate::di_container::asynchronous::IAsyncDIContainer; use crate::errors::injectable::InjectableError; use crate::provider::r#async::{AsyncProvidable, IAsyncProvider}; @@ -468,37 +389,6 @@ pub mod mocks } } } - - pub mod blocking_provider - { - use std::rc::Rc; - - use super::*; - use crate::di_container::blocking::IDIContainer; - use crate::errors::injectable::InjectableError; - use crate::provider::blocking::{IProvider, Providable}; - use crate::util::use_double; - - use_double!(crate::dependency_history::DependencyHistory); - - mock! { - pub Provider - where - DIContainerType: IDIContainer - {} - - impl IProvider for Provider - where - DIContainerType: IDIContainer, - { - fn provide( - &self, - di_container: &Rc, - dependency_history: DependencyHistory, - ) -> Result, InjectableError>; - } - } - } } #[cfg(all(feature = "async", feature = "factory"))] -- cgit v1.2.3-18-g5258