diff options
author | HampusM <hampus@hampusmat.com> | 2024-09-15 23:33:33 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2024-09-15 23:33:33 +0200 |
commit | d46181de1c19328ff8f3f6a12784cf14c53e9e71 (patch) | |
tree | 863bdd4e90ea2d9be66c3164222611cff2aca04a /src/di_container/asynchronous.rs | |
parent | a34f7c03779aaf90f34b5ff59587daf1db42de8d (diff) |
refactor!: rename to_*default_factory functions to to_*dynamic_value
BREAKING CHANGE: The functions to_default_factory and
to_async_default_factory have been renamed to to_dynamic_value and
to_async_dynamic_value, respectively
Diffstat (limited to 'src/di_container/asynchronous.rs')
-rw-r--r-- | src/di_container/asynchronous.rs | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/di_container/asynchronous.rs b/src/di_container/asynchronous.rs index c6308e6..a338c0a 100644 --- a/src/di_container/asynchronous.rs +++ b/src/di_container/asynchronous.rs @@ -371,20 +371,20 @@ impl AsyncDIContainer use crate::castable_function::threadsafe::ThreadsafeCastableFunction; use crate::ptr::TransientPtr; - type DefaultFactoryFn<Interface> = ThreadsafeCastableFunction< + type Func<Interface> = ThreadsafeCastableFunction< dyn Fn() -> TransientPtr<Interface> + Send + Sync, AsyncDIContainer, >; - let default_factory = func_bound + let dynamic_val_func = func_bound .as_any() - .downcast_ref::<DefaultFactoryFn<Interface>>() + .downcast_ref::<Func<Interface>>() .ok_or_else(|| AsyncDIContainerError::CastFailed { - interface: type_name::<DefaultFactoryFn<Interface>>(), - binding_kind: "default factory", + interface: type_name::<Func<Interface>>(), + binding_kind: "dynamic value func", })?; - Ok(SomePtr::Transient(default_factory.call(self)())) + Ok(SomePtr::Transient(dynamic_val_func.call(self)())) } #[cfg(feature = "factory")] AsyncProvidable::Function( @@ -395,22 +395,24 @@ impl AsyncDIContainer use crate::future::BoxFuture; use crate::ptr::TransientPtr; - type AsyncDefaultFactoryFn<Interface> = ThreadsafeCastableFunction< + type Func<Interface> = ThreadsafeCastableFunction< dyn Fn<(), Output = BoxFuture<'static, TransientPtr<Interface>>> + Send + Sync, AsyncDIContainer, >; - let async_default_factory = func_bound + let async_dynamic_value_func = func_bound .as_any() - .downcast_ref::<AsyncDefaultFactoryFn<Interface>>() + .downcast_ref::<Func<Interface>>() .ok_or_else(|| AsyncDIContainerError::CastFailed { - interface: type_name::<AsyncDefaultFactoryFn<Interface>>(), - binding_kind: "async default factory", + interface: type_name::<Func<Interface>>(), + binding_kind: "async dynamic value function", })?; - Ok(SomePtr::Transient(async_default_factory.call(self)().await)) + Ok(SomePtr::Transient( + async_dynamic_value_func.call(self)().await, + )) } } } |