diff options
author | HampusM <hampus@hampusmat.com> | 2022-08-21 14:19:07 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-08-21 18:17:51 +0200 |
commit | 8c66b98bca6ed0a2990903fe8e0ea72def5c7be8 (patch) | |
tree | deed78171051262dba7e8d97eba73a9aaf04dd5e /src/provider.rs | |
parent | b3e1b993b028bbfa73638236cfbdb50ee478d3f0 (diff) |
refactor!: change errors to be more sane
BREAKING CHANGE: Major improvements have been made to error types and the error_stack crate is no longer used
Diffstat (limited to 'src/provider.rs')
-rw-r--r-- | src/provider.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/provider.rs b/src/provider.rs index e12a12a..ad94589 100644 --- a/src/provider.rs +++ b/src/provider.rs @@ -1,12 +1,13 @@ #![allow(clippy::module_name_repetitions)] use std::marker::PhantomData; -use crate::errors::injectable::ResolveError; +use crate::errors::injectable::InjectableError; use crate::interfaces::any_factory::AnyFactory; use crate::interfaces::injectable::Injectable; use crate::ptr::{FactoryPtr, SingletonPtr, TransientPtr}; use crate::DIContainer; +#[derive(strum_macros::Display, Debug)] pub enum Providable { Transient(TransientPtr<dyn Injectable>), @@ -21,7 +22,7 @@ pub trait IProvider &self, di_container: &DIContainer, dependency_history: Vec<&'static str>, - ) -> error_stack::Result<Providable, ResolveError>; + ) -> Result<Providable, InjectableError>; } pub struct TransientTypeProvider<InjectableType> @@ -51,7 +52,7 @@ where &self, di_container: &DIContainer, dependency_history: Vec<&'static str>, - ) -> error_stack::Result<Providable, ResolveError> + ) -> Result<Providable, InjectableError> { Ok(Providable::Transient(InjectableType::resolve( di_container, @@ -85,7 +86,7 @@ where &self, _di_container: &DIContainer, _dependency_history: Vec<&'static str>, - ) -> error_stack::Result<Providable, ResolveError> + ) -> Result<Providable, InjectableError> { Ok(Providable::Singleton(self.singleton.clone())) } @@ -113,7 +114,7 @@ impl IProvider for FactoryProvider &self, _di_container: &DIContainer, _dependency_history: Vec<&'static str>, - ) -> error_stack::Result<Providable, ResolveError> + ) -> Result<Providable, InjectableError> { Ok(Providable::Factory(self.factory.clone())) } |