@@ -22,7 +22,7 @@ use crate::{
2222/// no-longer used modules. It is as such recommended to have the stores lifetime correspond to its
2323/// modules, and not repeatedly create and drop modules within an existing store, but rather create
2424/// a new store for it, to avoid unbounded memory use.
25- pub struct Store < T > {
25+ pub struct Store < T : ' static > {
2626 /// The internal store is kept behind a pointer.
2727 ///
2828 /// This is to allow referencing and reconstructing a calling context in exported functions,
@@ -58,7 +58,7 @@ pub struct Store<T> {
5858 inner : * mut StoreInner < T > ,
5959}
6060
61- impl < T > Store < T > {
61+ impl < T : ' static > Store < T > {
6262 /// Creates a new store from the inner box
6363 fn from_inner ( inner : Box < StoreInner < T > > ) -> Self {
6464 Self {
@@ -85,13 +85,13 @@ impl<T> Store<T> {
8585 }
8686}
8787
88- impl < T > Drop for Store < T > {
88+ impl < T : ' static > Drop for Store < T > {
8989 fn drop ( & mut self ) {
9090 unsafe { drop ( Box :: from_raw ( self . inner ) ) }
9191 }
9292}
9393
94- impl < T > WasmStore < T , Engine > for Store < T > {
94+ impl < T : ' static > WasmStore < T , Engine > for Store < T > {
9595 fn new ( engine : & Engine , data : T ) -> Self {
9696 #[ cfg( feature = "tracing" ) ]
9797 let _span = tracing:: debug_span!( "Store::new" ) . entered ( ) ;
@@ -135,29 +135,29 @@ impl<T> WasmStore<T, Engine> for Store<T> {
135135 }
136136}
137137
138- impl < T > AsContext < Engine > for Store < T > {
138+ impl < T : ' static > AsContext < Engine > for Store < T > {
139139 type UserState = T ;
140140
141141 fn as_context ( & self ) -> <Engine as WasmEngine >:: StoreContext < ' _ , Self :: UserState > {
142142 self . get ( )
143143 }
144144}
145145
146- impl < T > AsContextMut < Engine > for Store < T > {
146+ impl < T : ' static > AsContextMut < Engine > for Store < T > {
147147 fn as_context_mut ( & mut self ) -> StoreContextMut < T > {
148148 self . get_mut ( )
149149 }
150150}
151151
152- impl < T : fmt:: Debug > fmt:: Debug for Store < T > {
152+ impl < T : ' static + fmt:: Debug > fmt:: Debug for Store < T > {
153153 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
154154 self . inner . fmt ( f)
155155 }
156156}
157157
158158#[ derive( Debug ) ]
159159/// Holds the inner state of the store
160- pub struct StoreInner < T > {
160+ pub struct StoreInner < T : ' static > {
161161 /// The engine used
162162 pub ( crate ) engine : Engine ,
163163 /// Instances are not Send + Sync
@@ -181,7 +181,7 @@ pub struct StoreInner<T> {
181181 drop_resources : Vec < DropResource > ,
182182}
183183
184- impl < T > StoreInner < T > {
184+ impl < T : ' static > StoreInner < T > {
185185 /// Inserts a new function and returns its id
186186 pub ( crate ) fn insert_func ( & mut self , func : FuncInner ) -> Func {
187187 Func {
@@ -225,19 +225,19 @@ impl<T> StoreInner<T> {
225225}
226226
227227/// Immutable context to the store
228- pub struct StoreContext < ' a , T : ' a > {
228+ pub struct StoreContext < ' a , T : ' static > {
229229 /// The store
230230 store : & ' a StoreInner < T > ,
231231}
232232
233- impl < ' a , T : ' a > StoreContext < ' a , T > {
233+ impl < ' a , T : ' static > StoreContext < ' a , T > {
234234 /// Provides a store context from a reference
235235 pub fn from_ref ( store : & ' a StoreInner < T > ) -> Self {
236236 Self { store }
237237 }
238238}
239239
240- impl < T > Deref for StoreContext < ' _ , T > {
240+ impl < T : ' static > Deref for StoreContext < ' _ , T > {
241241 type Target = StoreInner < T > ;
242242
243243 fn deref ( & self ) -> & Self :: Target {
@@ -246,12 +246,12 @@ impl<T> Deref for StoreContext<'_, T> {
246246}
247247
248248/// Mutable context to the store
249- pub struct StoreContextMut < ' a , T : ' a > {
249+ pub struct StoreContextMut < ' a , T : ' static > {
250250 /// The store
251251 store : & ' a mut StoreInner < T > ,
252252}
253253
254- impl < ' a , T : ' a > StoreContextMut < ' a , T > {
254+ impl < ' a , T : ' static > StoreContextMut < ' a , T > {
255255 /// Returns a pointer to the inner store
256256 pub ( crate ) fn as_ptr ( & mut self ) -> * mut StoreInner < T > {
257257 self . store as * mut _
@@ -263,21 +263,21 @@ impl<'a, T: 'a> StoreContextMut<'a, T> {
263263 }
264264}
265265
266- impl < T > Deref for StoreContextMut < ' _ , T > {
266+ impl < T : ' static > Deref for StoreContextMut < ' _ , T > {
267267 type Target = StoreInner < T > ;
268268
269269 fn deref ( & self ) -> & Self :: Target {
270270 & * self . store
271271 }
272272}
273273
274- impl < T > DerefMut for StoreContextMut < ' _ , T > {
274+ impl < T : ' static > DerefMut for StoreContextMut < ' _ , T > {
275275 fn deref_mut ( & mut self ) -> & mut Self :: Target {
276276 & mut * self . store
277277 }
278278}
279279
280- impl < ' a , T : ' a > WasmStoreContext < ' a , T , Engine > for StoreContext < ' a , T > {
280+ impl < ' a , T : ' static > WasmStoreContext < ' a , T , Engine > for StoreContext < ' a , T > {
281281 fn engine ( & self ) -> & Engine {
282282 & self . engine
283283 }
@@ -287,15 +287,15 @@ impl<'a, T: 'a> WasmStoreContext<'a, T, Engine> for StoreContext<'a, T> {
287287 }
288288}
289289
290- impl < ' a , T : ' a > AsContext < Engine > for StoreContext < ' a , T > {
290+ impl < ' a , T : ' static > AsContext < Engine > for StoreContext < ' a , T > {
291291 type UserState = T ;
292292
293293 fn as_context ( & self ) -> StoreContext < ' _ , T > {
294294 StoreContext { store : self . store }
295295 }
296296}
297297
298- impl < ' a , T : ' a > WasmStoreContext < ' a , T , Engine > for StoreContextMut < ' a , T > {
298+ impl < ' a , T : ' static > WasmStoreContext < ' a , T , Engine > for StoreContextMut < ' a , T > {
299299 fn engine ( & self ) -> & Engine {
300300 & self . engine
301301 }
@@ -305,21 +305,21 @@ impl<'a, T: 'a> WasmStoreContext<'a, T, Engine> for StoreContextMut<'a, T> {
305305 }
306306}
307307
308- impl < ' a , T : ' a > WasmStoreContextMut < ' a , T , Engine > for StoreContextMut < ' a , T > {
308+ impl < ' a , T : ' static > WasmStoreContextMut < ' a , T , Engine > for StoreContextMut < ' a , T > {
309309 fn data_mut ( & mut self ) -> & mut T {
310310 & mut self . data
311311 }
312312}
313313
314- impl < ' a , T : ' a > AsContext < Engine > for StoreContextMut < ' a , T > {
314+ impl < ' a , T : ' static > AsContext < Engine > for StoreContextMut < ' a , T > {
315315 type UserState = T ;
316316
317317 fn as_context ( & self ) -> <Engine as WasmEngine >:: StoreContext < ' _ , T > {
318318 StoreContext { store : self . store }
319319 }
320320}
321321
322- impl < ' a , T : ' a > AsContextMut < Engine > for StoreContextMut < ' a , T > {
322+ impl < ' a , T : ' static > AsContextMut < Engine > for StoreContextMut < ' a , T > {
323323 fn as_context_mut ( & mut self ) -> StoreContextMut < ' _ , T > {
324324 StoreContextMut { store : self . store }
325325 }
0 commit comments