From 20d37eb93060e51970d3791c6c173e07ef5ad489 Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 11 Jul 2024 21:00:09 +0200 Subject: refactor: rename castable factory to castable function --- src/di_container/asynchronous/binding/builder.rs | 16 ++++++++-------- src/di_container/asynchronous/mod.rs | 20 ++++++++++---------- src/di_container/blocking/binding/builder.rs | 8 ++++---- src/di_container/blocking/mod.rs | 16 ++++++++-------- 4 files changed, 30 insertions(+), 30 deletions(-) (limited to 'src/di_container') diff --git a/src/di_container/asynchronous/binding/builder.rs b/src/di_container/asynchronous/binding/builder.rs index f42e6a1..8465c9a 100644 --- a/src/di_container/asynchronous/binding/builder.rs +++ b/src/di_container/asynchronous/binding/builder.rs @@ -173,7 +173,7 @@ where Interface: Fn + Send + Sync, FactoryFunc: Fn(&AsyncDIContainer) -> BoxFn + Send + Sync, { - use crate::castable_factory::threadsafe::ThreadsafeCastableFactory; + use crate::castable_function::threadsafe::ThreadsafeCastableFunction; use crate::provider::r#async::AsyncFactoryVariant; if self @@ -186,7 +186,7 @@ where ))); } - let factory_impl = ThreadsafeCastableFactory::new(factory_func); + let factory_impl = ThreadsafeCastableFunction::new(factory_func); self.di_container.set_binding::( BindingOptions::new(), @@ -270,7 +270,7 @@ where + Send + Sync, { - use crate::castable_factory::threadsafe::ThreadsafeCastableFactory; + use crate::castable_function::threadsafe::ThreadsafeCastableFunction; use crate::provider::r#async::AsyncFactoryVariant; if self @@ -283,7 +283,7 @@ where ))); } - let factory_impl = ThreadsafeCastableFactory::new(factory_func); + let factory_impl = ThreadsafeCastableFunction::new(factory_func); self.di_container.set_binding::( BindingOptions::new(), @@ -354,7 +354,7 @@ where + Send + Sync, { - use crate::castable_factory::threadsafe::ThreadsafeCastableFactory; + use crate::castable_function::threadsafe::ThreadsafeCastableFunction; use crate::provider::r#async::AsyncFactoryVariant; if self @@ -367,7 +367,7 @@ where ))); } - let factory_impl = ThreadsafeCastableFactory::new(factory_func); + let factory_impl = ThreadsafeCastableFunction::new(factory_func); self.di_container.set_binding::( BindingOptions::new(), @@ -445,7 +445,7 @@ where + Send + Sync, { - use crate::castable_factory::threadsafe::ThreadsafeCastableFactory; + use crate::castable_function::threadsafe::ThreadsafeCastableFunction; use crate::provider::r#async::AsyncFactoryVariant; if self @@ -458,7 +458,7 @@ where ))); } - let factory_impl = ThreadsafeCastableFactory::new(factory_func); + let factory_impl = ThreadsafeCastableFunction::new(factory_func); self.di_container.set_binding::( BindingOptions::new(), diff --git a/src/di_container/asynchronous/mod.rs b/src/di_container/asynchronous/mod.rs index 3e29ef6..c993b8b 100644 --- a/src/di_container/asynchronous/mod.rs +++ b/src/di_container/asynchronous/mod.rs @@ -348,11 +348,11 @@ impl AsyncDIContainer } #[cfg(feature = "factory")] AsyncProvidable::Factory(factory_binding) => { - use crate::castable_factory::threadsafe::ThreadsafeCastableFactory; + use crate::castable_function::threadsafe::ThreadsafeCastableFunction; let factory = factory_binding .as_any() - .downcast_ref::>() + .downcast_ref::>() .ok_or_else(|| AsyncDIContainerError::CastFailed { interface: type_name::(), binding_kind: "factory", @@ -362,10 +362,10 @@ impl AsyncDIContainer } #[cfg(feature = "factory")] AsyncProvidable::DefaultFactory(binding) => { - use crate::castable_factory::threadsafe::ThreadsafeCastableFactory; + use crate::castable_function::threadsafe::ThreadsafeCastableFunction; use crate::ptr::TransientPtr; - type DefaultFactoryFn = ThreadsafeCastableFactory< + type DefaultFactoryFn = ThreadsafeCastableFunction< dyn Fn() -> TransientPtr + Send + Sync, AsyncDIContainer, >; @@ -382,11 +382,11 @@ impl AsyncDIContainer } #[cfg(feature = "factory")] AsyncProvidable::AsyncDefaultFactory(binding) => { - use crate::castable_factory::threadsafe::ThreadsafeCastableFactory; + use crate::castable_function::threadsafe::ThreadsafeCastableFunction; use crate::future::BoxFuture; use crate::ptr::TransientPtr; - type AsyncDefaultFactoryFn = ThreadsafeCastableFactory< + type AsyncDefaultFactoryFn = ThreadsafeCastableFunction< dyn Fn<(), Output = BoxFuture<'static, TransientPtr>> + Send + Sync, @@ -652,7 +652,7 @@ mod tests } } - use crate::castable_factory::threadsafe::ThreadsafeCastableFactory; + use crate::castable_function::threadsafe::ThreadsafeCastableFunction; type IUserManagerFactory = dyn Fn(Vec) -> TransientPtr + Send + Sync; @@ -674,7 +674,7 @@ mod tests inner_mock_provider.expect_provide().returning(|_, _| { Ok(AsyncProvidable::Factory( crate::ptr::ThreadsafeFactoryPtr::new( - ThreadsafeCastableFactory::new(factory_func), + ThreadsafeCastableFunction::new(factory_func), ), )) }); @@ -734,7 +734,7 @@ mod tests } } - use crate::castable_factory::threadsafe::ThreadsafeCastableFactory; + use crate::castable_function::threadsafe::ThreadsafeCastableFunction; type IUserManagerFactory = dyn Fn(Vec) -> TransientPtr + Send + Sync; @@ -756,7 +756,7 @@ mod tests inner_mock_provider.expect_provide().returning(|_, _| { Ok(AsyncProvidable::Factory( crate::ptr::ThreadsafeFactoryPtr::new( - ThreadsafeCastableFactory::new(factory_func), + ThreadsafeCastableFunction::new(factory_func), ), )) }); diff --git a/src/di_container/blocking/binding/builder.rs b/src/di_container/blocking/binding/builder.rs index 9f7f6f9..ead1a54 100644 --- a/src/di_container/blocking/binding/builder.rs +++ b/src/di_container/blocking/binding/builder.rs @@ -181,7 +181,7 @@ where Interface: Fn>, Func: Fn(&DIContainer) -> Box, { - use crate::castable_factory::CastableFactory; + use crate::castable_function::CastableFunction; if self .di_container @@ -192,7 +192,7 @@ where >())); } - let factory_impl = CastableFactory::new(factory_func); + let factory_impl = CastableFunction::new(factory_func); self.di_container.set_binding::( BindingOptions::new(), @@ -269,7 +269,7 @@ where dyn Fn<(), Output = crate::ptr::TransientPtr>, >, { - use crate::castable_factory::CastableFactory; + use crate::castable_function::CastableFunction; if self .di_container @@ -280,7 +280,7 @@ where >())); } - let factory_impl = CastableFactory::new(factory_func); + let factory_impl = CastableFunction::new(factory_func); self.di_container.set_binding::( BindingOptions::new(), diff --git a/src/di_container/blocking/mod.rs b/src/di_container/blocking/mod.rs index d9efe94..d8b0d59 100644 --- a/src/di_container/blocking/mod.rs +++ b/src/di_container/blocking/mod.rs @@ -285,11 +285,11 @@ impl DIContainer )), #[cfg(feature = "factory")] Providable::Factory(factory_binding) => { - use crate::castable_factory::CastableFactory; + use crate::castable_function::CastableFunction; let factory = factory_binding .as_any() - .downcast_ref::>() + .downcast_ref::>() .ok_or_else(|| DIContainerError::CastFailed { interface: type_name::(), binding_kind: "factory", @@ -299,11 +299,11 @@ impl DIContainer } #[cfg(feature = "factory")] Providable::DefaultFactory(factory_binding) => { - use crate::castable_factory::CastableFactory; + use crate::castable_function::CastableFunction; use crate::ptr::TransientPtr; type DefaultFactoryFn = - CastableFactory TransientPtr, DIContainer>; + CastableFunction TransientPtr, DIContainer>; let default_factory = factory_binding .as_any() @@ -517,7 +517,7 @@ mod tests #[cfg(feature = "factory")] fn can_get_factory() { - use crate::castable_factory::CastableFactory; + use crate::castable_function::CastableFunction; use crate::ptr::FactoryPtr; trait IUserManager @@ -572,7 +572,7 @@ mod tests let mut mock_provider = MockIProvider::new(); mock_provider.expect_provide().returning_st(|_, _| { - Ok(Providable::Factory(FactoryPtr::new(CastableFactory::new( + Ok(Providable::Factory(FactoryPtr::new(CastableFunction::new( factory_func, )))) }); @@ -592,7 +592,7 @@ mod tests #[cfg(feature = "factory")] fn can_get_factory_named() { - use crate::castable_factory::CastableFactory; + use crate::castable_function::CastableFunction; use crate::ptr::FactoryPtr; trait IUserManager @@ -647,7 +647,7 @@ mod tests let mut mock_provider = MockIProvider::new(); mock_provider.expect_provide().returning_st(|_, _| { - Ok(Providable::Factory(FactoryPtr::new(CastableFactory::new( + Ok(Providable::Factory(FactoryPtr::new(CastableFunction::new( factory_func, )))) }); -- cgit v1.2.3-18-g5258