From 2d1a6b2d432408d74eb57e0bda3f7434617e1070 Mon Sep 17 00:00:00 2001 From: HampusM Date: Wed, 20 Jul 2022 14:29:45 +0200 Subject: refactor: reorganize folder hierarchy --- src/interfaces/factory.rs | 10 ++++++++++ src/interfaces/injectable.rs | 17 +++++++++++++++++ src/interfaces/mod.rs | 2 ++ 3 files changed, 29 insertions(+) create mode 100644 src/interfaces/factory.rs create mode 100644 src/interfaces/injectable.rs create mode 100644 src/interfaces/mod.rs (limited to 'src/interfaces') diff --git a/src/interfaces/factory.rs b/src/interfaces/factory.rs new file mode 100644 index 0000000..c97fc09 --- /dev/null +++ b/src/interfaces/factory.rs @@ -0,0 +1,10 @@ +#![allow(clippy::module_name_repetitions)] +use crate::libs::intertrait::CastFrom; +use crate::ptr::InterfacePtr; + +pub trait IFactory: + Fn> + CastFrom +where + ReturnInterface: 'static + ?Sized, +{ +} diff --git a/src/interfaces/injectable.rs b/src/interfaces/injectable.rs new file mode 100644 index 0000000..24032a6 --- /dev/null +++ b/src/interfaces/injectable.rs @@ -0,0 +1,17 @@ +use crate::errors::injectable::ResolveError; +use crate::libs::intertrait::CastFrom; +use crate::ptr::InterfacePtr; +use crate::DIContainer; + +pub trait Injectable: CastFrom +{ + /// Resolves the dependencies of the injectable. + /// + /// # Errors + /// Will return `Err` if resolving the dependencies fails. + fn resolve( + di_container: &DIContainer, + ) -> error_stack::Result, ResolveError> + where + Self: Sized; +} diff --git a/src/interfaces/mod.rs b/src/interfaces/mod.rs new file mode 100644 index 0000000..921bb9c --- /dev/null +++ b/src/interfaces/mod.rs @@ -0,0 +1,2 @@ +pub mod factory; +pub mod injectable; -- cgit v1.2.3-18-g5258