@@ -81,33 +81,49 @@ const MAX_EVENT_KEY_LEN: usize = 64;
81
81
const MAX_STREAM_NAME_LEN : usize = 64 ;
82
82
83
83
/// An implementation of [`UserContractModule`].
84
- pub type UserContractCode = Arc < dyn UserContractModule + Send + Sync + ' static > ;
84
+ pub type UserContractCode = Box < dyn UserContractModule + Send + Sync > ;
85
85
86
86
/// An implementation of [`UserServiceModule`].
87
- pub type UserServiceCode = Arc < dyn UserServiceModule + Send + Sync + ' static > ;
87
+ pub type UserServiceCode = Box < dyn UserServiceModule + Send + Sync > ;
88
88
89
89
/// An implementation of [`UserContract`].
90
- pub type UserContractInstance = Box < dyn UserContract + ' static > ;
90
+ pub type UserContractInstance = Box < dyn UserContract > ;
91
91
92
92
/// An implementation of [`UserService`].
93
- pub type UserServiceInstance = Box < dyn UserService + ' static > ;
93
+ pub type UserServiceInstance = Box < dyn UserService > ;
94
94
95
95
/// A factory trait to obtain a [`UserContract`] from a [`UserContractModule`]
96
- pub trait UserContractModule {
96
+ pub trait UserContractModule : dyn_clone :: DynClone {
97
97
fn instantiate (
98
98
& self ,
99
99
runtime : ContractSyncRuntimeHandle ,
100
100
) -> Result < UserContractInstance , ExecutionError > ;
101
101
}
102
102
103
+ impl < T : UserContractModule + Send + Sync + ' static > From < T > for UserContractCode {
104
+ fn from ( module : T ) -> Self {
105
+ Box :: new ( module)
106
+ }
107
+ }
108
+
109
+ dyn_clone:: clone_trait_object!( UserContractModule ) ;
110
+
103
111
/// A factory trait to obtain a [`UserService`] from a [`UserServiceModule`]
104
- pub trait UserServiceModule {
112
+ pub trait UserServiceModule : dyn_clone :: DynClone {
105
113
fn instantiate (
106
114
& self ,
107
115
runtime : ServiceSyncRuntimeHandle ,
108
116
) -> Result < UserServiceInstance , ExecutionError > ;
109
117
}
110
118
119
+ impl < T : UserServiceModule + Send + Sync + ' static > From < T > for UserServiceCode {
120
+ fn from ( module : T ) -> Self {
121
+ Box :: new ( module)
122
+ }
123
+ }
124
+
125
+ dyn_clone:: clone_trait_object!( UserServiceModule ) ;
126
+
111
127
/// A type for errors happening during execution.
112
128
#[ derive( Error , Debug ) ]
113
129
pub enum ExecutionError {
0 commit comments