diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/castable_factory.rs | 8 | ||||
-rw-r--r-- | src/di_container.rs | 22 | ||||
-rw-r--r-- | src/interfaces/factory.rs | 4 | ||||
-rw-r--r-- | src/interfaces/injectable.rs | 4 | ||||
-rw-r--r-- | src/provider.rs | 4 | ||||
-rw-r--r-- | src/ptr.rs | 2 |
6 files changed, 22 insertions, 22 deletions
diff --git a/src/castable_factory.rs b/src/castable_factory.rs index c50456c..5ff4db0 100644 --- a/src/castable_factory.rs +++ b/src/castable_factory.rs @@ -1,13 +1,13 @@ use crate::interfaces::any_factory::AnyFactory; use crate::interfaces::factory::IFactory; -use crate::ptr::InterfacePtr; +use crate::ptr::TransientPtr; pub struct CastableFactory<Args, ReturnInterface> where Args: 'static, ReturnInterface: 'static + ?Sized, { - func: &'static dyn Fn<Args, Output = InterfacePtr<ReturnInterface>>, + func: &'static dyn Fn<Args, Output = TransientPtr<ReturnInterface>>, } impl<Args, ReturnInterface> CastableFactory<Args, ReturnInterface> @@ -16,7 +16,7 @@ where ReturnInterface: 'static + ?Sized, { pub fn new( - func: &'static dyn Fn<Args, Output = InterfacePtr<ReturnInterface>>, + func: &'static dyn Fn<Args, Output = TransientPtr<ReturnInterface>>, ) -> Self { Self { func } @@ -58,7 +58,7 @@ where Args: 'static, ReturnInterface: 'static + ?Sized, { - type Output = InterfacePtr<ReturnInterface>; + type Output = TransientPtr<ReturnInterface>; extern "rust-call" fn call_once(self, args: Args) -> Self::Output { diff --git a/src/di_container.rs b/src/di_container.rs index 1f7700f..d1c757d 100644 --- a/src/di_container.rs +++ b/src/di_container.rs @@ -11,7 +11,7 @@ use crate::errors::di_container::DIContainerError; use crate::interfaces::injectable::Injectable; use crate::libs::intertrait::cast::CastBox; use crate::provider::{IProvider, InjectableTypeProvider, Providable}; -use crate::ptr::InterfacePtr; +use crate::ptr::TransientPtr; /// Binding builder for type `Interface` inside a [`DIContainer`]. pub struct BindingBuilder<'di_container_lt, Interface> @@ -53,7 +53,7 @@ where #[cfg(feature = "factory")] pub fn to_factory<Args, Return>( &mut self, - factory_func: &'static dyn Fn<Args, Output = InterfacePtr<Return>>, + factory_func: &'static dyn Fn<Args, Output = TransientPtr<Return>>, ) where Args: 'static, Return: 'static + ?Sized, @@ -151,7 +151,7 @@ impl DIContainer /// - The binding for `Interface` is not injectable pub fn get<Interface>( &self, - ) -> error_stack::Result<InterfacePtr<Interface>, DIContainerError> + ) -> error_stack::Result<TransientPtr<Interface>, DIContainerError> where Interface: 'static + ?Sized, { @@ -260,7 +260,7 @@ mod tests use super::*; use crate::errors::injectable::ResolveError; - use crate::ptr::InterfacePtr; + use crate::ptr::TransientPtr; #[test] fn can_bind_to() @@ -292,13 +292,13 @@ mod tests fn resolve( _di_container: &DIContainer, ) -> error_stack::Result< - InterfacePtr<Self>, + TransientPtr<Self>, crate::errors::injectable::ResolveError, > where Self: Sized, { - Ok(InterfacePtr::new(Self {})) + Ok(TransientPtr::new(Self {})) } } @@ -353,8 +353,8 @@ mod tests assert_eq!(di_container.bindings.len(), 0); di_container.bind::<IUserManagerFactory>().to_factory(&|| { - let user_manager: InterfacePtr<dyn IUserManager> = - InterfacePtr::new(UserManager::new()); + let user_manager: TransientPtr<dyn IUserManager> = + TransientPtr::new(UserManager::new()); user_manager }); @@ -417,7 +417,7 @@ mod tests mock_provider.expect_provide().returning(|_| { Ok(Providable::Injectable( - InterfacePtr::new(UserManager::new()), + TransientPtr::new(UserManager::new()), )) }); @@ -495,8 +495,8 @@ mod tests mock_provider.expect_provide().returning(|_| { Ok(Providable::Factory(crate::ptr::FactoryPtr::new( CastableFactory::new(&|users| { - let user_manager: InterfacePtr<dyn IUserManager> = - InterfacePtr::new(UserManager::new(users)); + let user_manager: TransientPtr<dyn IUserManager> = + TransientPtr::new(UserManager::new(users)); user_manager }), diff --git a/src/interfaces/factory.rs b/src/interfaces/factory.rs index c97fc09..6f8e7c7 100644 --- a/src/interfaces/factory.rs +++ b/src/interfaces/factory.rs @@ -1,9 +1,9 @@ #![allow(clippy::module_name_repetitions)] use crate::libs::intertrait::CastFrom; -use crate::ptr::InterfacePtr; +use crate::ptr::TransientPtr; pub trait IFactory<Args, ReturnInterface>: - Fn<Args, Output = InterfacePtr<ReturnInterface>> + CastFrom + Fn<Args, Output = TransientPtr<ReturnInterface>> + CastFrom where ReturnInterface: 'static + ?Sized, { diff --git a/src/interfaces/injectable.rs b/src/interfaces/injectable.rs index 24032a6..0af1217 100644 --- a/src/interfaces/injectable.rs +++ b/src/interfaces/injectable.rs @@ -1,6 +1,6 @@ use crate::errors::injectable::ResolveError; use crate::libs::intertrait::CastFrom; -use crate::ptr::InterfacePtr; +use crate::ptr::TransientPtr; use crate::DIContainer; pub trait Injectable: CastFrom @@ -11,7 +11,7 @@ pub trait Injectable: CastFrom /// Will return `Err` if resolving the dependencies fails. fn resolve( di_container: &DIContainer, - ) -> error_stack::Result<InterfacePtr<Self>, ResolveError> + ) -> error_stack::Result<TransientPtr<Self>, ResolveError> where Self: Sized; } diff --git a/src/provider.rs b/src/provider.rs index bd17474..eb5b5d8 100644 --- a/src/provider.rs +++ b/src/provider.rs @@ -4,14 +4,14 @@ use std::marker::PhantomData; use crate::errors::injectable::ResolveError; use crate::interfaces::any_factory::AnyFactory; use crate::interfaces::injectable::Injectable; -use crate::ptr::{FactoryPtr, InterfacePtr}; +use crate::ptr::{FactoryPtr, TransientPtr}; use crate::DIContainer; extern crate error_stack; pub enum Providable { - Injectable(InterfacePtr<dyn Injectable>), + Injectable(TransientPtr<dyn Injectable>), #[allow(dead_code)] Factory(FactoryPtr<dyn AnyFactory>), } @@ -1,6 +1,6 @@ #![allow(clippy::module_name_repetitions)] use std::rc::Rc; -pub type InterfacePtr<Interface> = Box<Interface>; +pub type TransientPtr<Interface> = Box<Interface>; pub type FactoryPtr<FactoryInterface> = Rc<FactoryInterface>; |