aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/injectable.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-12-25 22:53:13 +0100
committerHampusM <hampus@hampusmat.com>2023-12-28 12:00:11 +0100
commit607d8d50b76665b67ca6f3124aa81773bec110b7 (patch)
tree142a7c17c4e254eabd5a5396975921bca1869bec /src/interfaces/injectable.rs
parentc501a5cc770f632eba1529de09bd3ae2d7958de6 (diff)
WIP Linkme dependency removalwithout-linkme
Diffstat (limited to 'src/interfaces/injectable.rs')
-rw-r--r--src/interfaces/injectable.rs30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/interfaces/injectable.rs b/src/interfaces/injectable.rs
index 1d3a1a7..eb0839c 100644
--- a/src/interfaces/injectable.rs
+++ b/src/interfaces/injectable.rs
@@ -1,15 +1,17 @@
//! Interface for structs that can be injected into or be injected to.
use std::fmt::Debug;
+use std::rc::Rc;
+use std::sync::Arc;
use crate::errors::injectable::InjectableError;
-use crate::private::cast::CastFrom;
use crate::ptr::TransientPtr;
+use crate::ptr_buffer::{PtrBuffer, SmartPtr};
use crate::util::use_double;
use_double!(crate::dependency_history::DependencyHistory);
/// Interface for structs that can be injected into or be injected to.
-pub trait Injectable<DIContainerT>: CastFrom
+pub trait Injectable<DIContainerT>: 'static
{
/// Resolves the dependencies of the injectable.
///
@@ -21,6 +23,15 @@ pub trait Injectable<DIContainerT>: CastFrom
) -> Result<TransientPtr<Self>, InjectableError>
where
Self: Sized;
+
+ /// A.
+ fn into_ptr_buffer_box(self: Box<Self>) -> PtrBuffer;
+
+ /// A.
+ fn into_ptr_buffer_rc(self: Rc<Self>) -> PtrBuffer;
+
+ /// A.
+ fn into_ptr_buffer_arc(self: Arc<Self>) -> PtrBuffer;
}
impl<DIContainerT> Debug for dyn Injectable<DIContainerT>
@@ -42,4 +53,19 @@ where
{
Ok(TransientPtr::new(Self::default()))
}
+
+ fn into_ptr_buffer_box(self: Box<Self>) -> PtrBuffer
+ {
+ PtrBuffer::new_from(SmartPtr::Box(self))
+ }
+
+ fn into_ptr_buffer_rc(self: Rc<Self>) -> PtrBuffer
+ {
+ PtrBuffer::new_from(SmartPtr::Rc(self))
+ }
+
+ fn into_ptr_buffer_arc(self: Arc<Self>) -> PtrBuffer
+ {
+ PtrBuffer::new_from(SmartPtr::Arc(self))
+ }
}