11use async_trait:: async_trait;
22use serde:: { Serialize , de:: DeserializeOwned } ;
33use serde_json:: Value as JsonValue ;
4- use std:: sync :: Arc ;
4+ use std:: marker :: PhantomData ;
55
66use crate :: context:: TaskContext ;
77use crate :: error:: { TaskError , TaskResult } ;
@@ -110,34 +110,8 @@ where
110110 ) -> Result < JsonValue , TaskError > ;
111111}
112112
113- /// Wrapper that implements ErasedTask for any Task type
114- pub struct TaskWrapper < T , State > ( std:: marker:: PhantomData < ( T , State ) > )
115- where
116- T : Task < State > ,
117- State : Clone + Send + Sync + ' static ;
118-
119- impl < T , State > TaskWrapper < T , State >
120- where
121- T : Task < State > ,
122- State : Clone + Send + Sync + ' static ,
123- {
124- pub fn new ( ) -> Self {
125- Self ( std:: marker:: PhantomData )
126- }
127- }
128-
129- impl < T , State > Default for TaskWrapper < T , State >
130- where
131- T : Task < State > ,
132- State : Clone + Send + Sync + ' static ,
133- {
134- fn default ( ) -> Self {
135- Self :: new ( )
136- }
137- }
138-
139113#[ async_trait]
140- impl < T , State > ErasedTask < State > for TaskWrapper < T , State >
114+ impl < T , State > ErasedTask < State > for PhantomData < T >
141115where
142116 T : Task < State > ,
143117 State : Clone + Send + Sync + ' static ,
@@ -159,4 +133,4 @@ where
159133}
160134
161135/// Type alias for the task registry
162- pub type TaskRegistry < State > = std:: collections:: HashMap < String , Arc < dyn ErasedTask < State > > > ;
136+ pub type TaskRegistry < State > = std:: collections:: HashMap < String , & ' static dyn ErasedTask < State > > ;
0 commit comments