11use crate :: app:: KvStoreOption ;
22use key_value_store:: KeyValueStore ;
33use std:: { fmt:: Debug , ops:: Deref } ;
4- use wasmtime :: component :: ResourceTable ;
5- use wasmtime_wasi:: IoView ;
4+ use wasmtime_wasi :: ResourceTable ;
5+ use wasmtime_wasi:: WasiCtxView ;
66use wasmtime_wasi_http:: { HttpResult , WasiHttpCtx , WasiHttpView } ;
7+ use wasmtime_wasi_io:: IoView ;
78
89use crate :: store:: StoreBuilder ;
910use http_backend:: Backend ;
@@ -78,7 +79,7 @@ pub enum Wasi {
7879}
7980
8081/// Host state data associated with individual [Store]s and [Instance]s.
81- pub struct Data < T > {
82+ pub struct Data < T : ' static > {
8283 inner : T ,
8384 wasi : Wasi ,
8485 pub wasi_nn : WasiNnCtx ,
@@ -141,6 +142,10 @@ impl<T: Send + BackendRequest> WasiHttpView for Data<T> {
141142 } ,
142143 ) )
143144 }
145+
146+ fn table ( & mut self ) -> & mut ResourceTable {
147+ & mut self . table
148+ }
144149}
145150
146151impl < T > Data < T > {
@@ -191,12 +196,15 @@ impl AsRef<wasmtime::Config> for WasmConfig {
191196}
192197
193198impl < T : Send > wasmtime_wasi:: WasiView for Data < T > {
194- fn ctx ( & mut self ) -> & mut wasmtime_wasi :: WasiCtx {
199+ fn ctx ( & mut self ) -> WasiCtxView < ' _ > {
195200 match & mut self . wasi {
196201 Wasi :: Preview1 ( _) => {
197202 unreachable ! ( "using WASI Preview 1 functions with Preview 2 store" )
198203 }
199- Wasi :: Preview2 ( ctx) => ctx,
204+ Wasi :: Preview2 ( ctx) => WasiCtxView {
205+ ctx,
206+ table : & mut self . table ,
207+ } ,
200208 }
201209 }
202210}
@@ -302,7 +310,7 @@ pub type ComponentLinker<T> = wasmtime::component::Linker<Data<T>>;
302310pub type ModuleLinker < T > = wasmtime:: Linker < Data < T > > ;
303311
304312/// An `WasmEngine` is a global context for the initialization and execution of WASM application.
305- pub struct WasmEngine < T > {
313+ pub struct WasmEngine < T : ' static > {
306314 inner : Engine ,
307315 component_linker : ComponentLinker < T > ,
308316 module_linker : ModuleLinker < T > ,
@@ -311,7 +319,7 @@ pub struct WasmEngine<T> {
311319/// A builder interface for configuring a new [`WasmEngine`].
312320///
313321/// A new [`WasmEngineBuilder`] can be obtained with [`WasmEngine::builder`].
314- pub struct WasmEngineBuilder < T > {
322+ pub struct WasmEngineBuilder < T : ' static > {
315323 engine : Engine ,
316324 component_linker : ComponentLinker < T > ,
317325 module_linker : ModuleLinker < T > ,
@@ -385,7 +393,7 @@ pub trait PreCompiledLoader<K> {
385393}
386394
387395pub trait ContextT {
388- type BackendConnector ;
396+ type BackendConnector : ' static ;
389397
390398 fn make_logger ( & self , app_name : SmolStr , wrk : & App ) -> Logger ;
391399
0 commit comments