aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-09-16 15:40:45 +0200
committerHampusM <hampus@hampusmat.com>2023-09-16 15:40:45 +0200
commit31f7949ab380bcd0a0b754588e7d50284d2f5ae7 (patch)
tree0043e4379d63112e98acd3149145bd2fc4db0b2b
parent8b4cb39890016394122a799929aee6662980025b (diff)
refactor: move DI container get_binding_providable to other impl
The get_binding_providable method doesn't need to be mocked so it should be moved to a non mocked impl
-rw-r--r--src/di_container/blocking/mod.rs61
1 files changed, 32 insertions, 29 deletions
diff --git a/src/di_container/blocking/mod.rs b/src/di_container/blocking/mod.rs
index 548f716..1ee0294 100644
--- a/src/di_container/blocking/mod.rs
+++ b/src/di_container/blocking/mod.rs
@@ -237,35 +237,6 @@ impl DIContainer
}
}
- fn get_binding_providable<Interface>(
- self: &Rc<Self>,
- binding_options: BindingOptionsWithLt,
- dependency_history: DependencyHistory,
- ) -> Result<Providable<Self>, DIContainerError>
- where
- Interface: 'static + ?Sized,
- {
- let name = binding_options.name;
-
- self.binding_storage
- .borrow()
- .get::<Interface>(binding_options)
- .map_or_else(
- || {
- Err(DIContainerError::BindingNotFound {
- interface: type_name::<Interface>(),
- name: name.as_ref().map(ToString::to_string),
- })
- },
- Ok,
- )?
- .provide(self, dependency_history)
- .map_err(|err| DIContainerError::BindingResolveFailed {
- reason: err,
- interface: type_name::<Interface>(),
- })
- }
-
fn has_binding<Interface>(
self: &Rc<Self>,
binding_options: BindingOptionsWithLt,
@@ -303,6 +274,38 @@ impl DIContainer
}
}
+impl DIContainer
+{
+ fn get_binding_providable<Interface>(
+ self: &Rc<Self>,
+ binding_options: BindingOptionsWithLt,
+ dependency_history: DependencyHistory,
+ ) -> Result<Providable<Self>, DIContainerError>
+ where
+ Interface: 'static + ?Sized,
+ {
+ let name = binding_options.name;
+
+ self.binding_storage
+ .borrow()
+ .get::<Interface>(binding_options)
+ .map_or_else(
+ || {
+ Err(DIContainerError::BindingNotFound {
+ interface: type_name::<Interface>(),
+ name: name.as_ref().map(ToString::to_string),
+ })
+ },
+ Ok,
+ )?
+ .provide(self, dependency_history)
+ .map_err(|err| DIContainerError::BindingResolveFailed {
+ reason: err,
+ interface: type_name::<Interface>(),
+ })
+ }
+}
+
#[cfg(test)]
mod tests
{