From 607d8d50b76665b67ca6f3124aa81773bec110b7 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 25 Dec 2023 22:53:13 +0100 Subject: WIP Linkme dependency removal --- src/test_utils.rs | 106 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 91 insertions(+), 15 deletions(-) (limited to 'src/test_utils.rs') 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 Injectable for UserManager { fn resolve( @@ -58,6 +55,27 @@ pub mod subjects { Ok(TransientPtr::new(Self::new())) } + + fn into_ptr_buffer_box(self: Box) -> PtrBuffer + { + let me: Box = self; + + PtrBuffer::new_from(me) + } + + fn into_ptr_buffer_rc(self: Rc) -> PtrBuffer + { + let me: Rc = self; + + PtrBuffer::new_from(me) + } + + fn into_ptr_buffer_arc(self: Arc) -> PtrBuffer + { + let me: Arc = self; + + PtrBuffer::new_from(me) + } } pub trait INumber @@ -109,8 +127,6 @@ pub mod subjects } } - declare_interface!(Number -> INumber); - impl Injectable for Number { fn resolve( @@ -122,12 +138,33 @@ pub mod subjects { Ok(TransientPtr::new(Self::new())) } + + fn into_ptr_buffer_box(self: Box) -> PtrBuffer + { + let me: Box = self; + + PtrBuffer::new_from(me) + } + + fn into_ptr_buffer_rc(self: Rc) -> PtrBuffer + { + let me: Rc = self; + + PtrBuffer::new_from(me) + } + + fn into_ptr_buffer_arc(self: Arc) -> PtrBuffer + { + let me: Arc = 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 AsyncInjectable for UserManager { @@ -194,6 +230,27 @@ pub mod subjects_async { Ok(TransientPtr::new(Self::new())) } + + fn into_ptr_buffer_box(self: Box) -> PtrBuffer + { + let me: Box = self; + + PtrBuffer::new_from(me) + } + + fn into_ptr_buffer_rc(self: Rc) -> PtrBuffer + { + let me: Rc = self; + + PtrBuffer::new_from(me) + } + + fn into_ptr_buffer_arc(self: Arc) -> PtrBuffer + { + let me: Arc = 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 AsyncInjectable for Number { @@ -259,6 +314,27 @@ pub mod subjects_async { Ok(TransientPtr::new(Self::new())) } + + fn into_ptr_buffer_box(self: Box) -> PtrBuffer + { + let me: Box = self; + + PtrBuffer::new_from(me) + } + + fn into_ptr_buffer_rc(self: Rc) -> PtrBuffer + { + let me: Rc = self; + + PtrBuffer::new_from(me) + } + + fn into_ptr_buffer_arc(self: Arc) -> PtrBuffer + { + let me: Arc = self; + + PtrBuffer::new_from(me) + } } } -- cgit v1.2.3-18-g5258