aboutsummaryrefslogtreecommitdiff
path: root/syrette/src/injectable.rs
diff options
context:
space:
mode:
Diffstat (limited to 'syrette/src/injectable.rs')
-rw-r--r--syrette/src/injectable.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/syrette/src/injectable.rs b/syrette/src/injectable.rs
new file mode 100644
index 0000000..3cc0d7f
--- /dev/null
+++ b/syrette/src/injectable.rs
@@ -0,0 +1,29 @@
+use core::fmt;
+use std::fmt::{Display, Formatter};
+
+use error_stack::Context;
+
+use crate::libs::intertrait::CastFrom;
+use crate::DIContainer;
+
+#[derive(Debug)]
+pub struct ResolveError;
+
+impl Display for ResolveError
+{
+ fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result
+ {
+ fmt.write_str("Failed to resolve injectable struct")
+ }
+}
+
+impl Context for ResolveError {}
+
+pub trait Injectable: CastFrom
+{
+ fn resolve(
+ di_container: &DIContainer,
+ ) -> error_stack::Result<Box<Self>, ResolveError>
+ where
+ Self: Sized;
+}