aboutsummaryrefslogtreecommitdiff
path: root/src/test_utils.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/test_utils.rs
parentc501a5cc770f632eba1529de09bd3ae2d7958de6 (diff)
WIP Linkme dependency removalwithout-linkme
Diffstat (limited to 'src/test_utils.rs')
-rw-r--r--src/test_utils.rs106
1 files changed, 91 insertions, 15 deletions
diff --git a/src/test_utils.rs b/src/test_utils.rs
index 491e9b4..f0858b5 100644
--- a/src/test_utils.rs
+++ b/src/test_utils.rs
@@ -3,11 +3,10 @@ pub mod subjects
//! Test subjects.
use std::fmt::Debug;
-
- use syrette_macros::declare_interface;
+ use std::rc::Rc;
+ use std::sync::Arc;
use crate::interfaces::injectable::Injectable;
- use crate::private::cast::CastFromArc;
use crate::ptr::TransientPtr;
use_double!(crate::dependency_history::DependencyHistory);
@@ -42,11 +41,9 @@ pub mod subjects
}
}
- use crate as syrette;
+ use crate::ptr_buffer::PtrBuffer;
use crate::util::use_double;
- declare_interface!(UserManager -> IUserManager);
-
impl<DIContainerT> Injectable<DIContainerT> for UserManager
{
fn resolve(
@@ -58,6 +55,27 @@ pub mod subjects
{
Ok(TransientPtr::new(Self::new()))
}
+
+ fn into_ptr_buffer_box(self: Box<Self>) -> PtrBuffer
+ {
+ let me: Box<dyn IUserManager> = self;
+
+ PtrBuffer::new_from(me)
+ }
+
+ fn into_ptr_buffer_rc(self: Rc<Self>) -> PtrBuffer
+ {
+ let me: Rc<dyn IUserManager> = self;
+
+ PtrBuffer::new_from(me)
+ }
+
+ fn into_ptr_buffer_arc(self: Arc<Self>) -> PtrBuffer
+ {
+ let me: Arc<dyn IUserManager> = self;
+
+ PtrBuffer::new_from(me)
+ }
}
pub trait INumber
@@ -109,8 +127,6 @@ pub mod subjects
}
}
- declare_interface!(Number -> INumber);
-
impl<DIContainerT> Injectable<DIContainerT> for Number
{
fn resolve(
@@ -122,12 +138,33 @@ pub mod subjects
{
Ok(TransientPtr::new(Self::new()))
}
+
+ fn into_ptr_buffer_box(self: Box<Self>) -> PtrBuffer
+ {
+ let me: Box<dyn INumber> = self;
+
+ PtrBuffer::new_from(me)
+ }
+
+ fn into_ptr_buffer_rc(self: Rc<Self>) -> PtrBuffer
+ {
+ let me: Rc<dyn INumber> = self;
+
+ PtrBuffer::new_from(me)
+ }
+
+ fn into_ptr_buffer_arc(self: Arc<Self>) -> PtrBuffer
+ {
+ let me: Arc<dyn INumber> = self;
+
+ PtrBuffer::new_from(me)
+ }
}
#[derive(Debug)]
pub struct Ninja;
- pub trait INinja: CastFromArc {}
+ pub trait INinja {}
impl INinja for Ninja {}
}
@@ -138,9 +175,10 @@ pub mod subjects_async
//! Test subjects.
use std::fmt::Debug;
+ use std::rc::Rc;
+ use std::sync::Arc;
use async_trait::async_trait;
- use syrette_macros::declare_interface;
use crate::interfaces::async_injectable::AsyncInjectable;
use crate::ptr::TransientPtr;
@@ -177,11 +215,9 @@ pub mod subjects_async
}
}
- use crate as syrette;
+ use crate::ptr_buffer::PtrBuffer;
use crate::util::use_double;
- declare_interface!(UserManager -> IUserManager);
-
#[async_trait]
impl<DIContainerType> AsyncInjectable<DIContainerType> for UserManager
{
@@ -194,6 +230,27 @@ pub mod subjects_async
{
Ok(TransientPtr::new(Self::new()))
}
+
+ fn into_ptr_buffer_box(self: Box<Self>) -> PtrBuffer
+ {
+ let me: Box<dyn IUserManager> = self;
+
+ PtrBuffer::new_from(me)
+ }
+
+ fn into_ptr_buffer_rc(self: Rc<Self>) -> PtrBuffer
+ {
+ let me: Rc<dyn IUserManager> = self;
+
+ PtrBuffer::new_from(me)
+ }
+
+ fn into_ptr_buffer_arc(self: Arc<Self>) -> PtrBuffer
+ {
+ let me: Arc<dyn IUserManager> = self;
+
+ PtrBuffer::new_from(me)
+ }
}
pub trait INumber: Send + Sync
@@ -245,8 +302,6 @@ pub mod subjects_async
}
}
- declare_interface!(Number -> INumber, threadsafe_sharable = true);
-
#[async_trait]
impl<DIContainerType> AsyncInjectable<DIContainerType> for Number
{
@@ -259,6 +314,27 @@ pub mod subjects_async
{
Ok(TransientPtr::new(Self::new()))
}
+
+ fn into_ptr_buffer_box(self: Box<Self>) -> PtrBuffer
+ {
+ let me: Box<dyn INumber> = self;
+
+ PtrBuffer::new_from(me)
+ }
+
+ fn into_ptr_buffer_rc(self: Rc<Self>) -> PtrBuffer
+ {
+ let me: Rc<dyn INumber> = self;
+
+ PtrBuffer::new_from(me)
+ }
+
+ fn into_ptr_buffer_arc(self: Arc<Self>) -> PtrBuffer
+ {
+ let me: Arc<dyn INumber> = self;
+
+ PtrBuffer::new_from(me)
+ }
}
}