1313
1414use std:: path:: { Path , PathBuf } ;
1515
16- use wasmtime_wasi:: { ResourceTable , WasiCtx , WasiCtxBuilder , WasiView } ;
16+ use wasmtime_wasi:: { ResourceTable , WasiCtx , WasiCtxBuilder , WasiCtxView , WasiView } ;
1717
1818/// Minimal store data that satisfies WasiView for component instantiation.
1919struct TestStoreData {
@@ -31,12 +31,11 @@ impl TestStoreData {
3131}
3232
3333impl WasiView for TestStoreData {
34- fn ctx ( & mut self ) -> & mut WasiCtx {
35- & mut self . wasi
36- }
37-
38- fn table ( & mut self ) -> & mut ResourceTable {
39- & mut self . table
34+ fn ctx ( & mut self ) -> WasiCtxView < ' _ > {
35+ WasiCtxView {
36+ ctx : & mut self . wasi ,
37+ table : & mut self . table ,
38+ }
4039 }
4140}
4241
@@ -167,30 +166,30 @@ fn compile_component(
167166fn stub_shared_host_functions (
168167 host : & mut wasmtime:: component:: LinkerInstance < ' _ , TestStoreData > ,
169168) -> Result < ( ) , String > {
170- host. func_new ( "log" , |_ctx, _args, _results| Ok ( ( ) ) )
169+ host. func_new ( "log" , |_ctx, _ty , _args, _results| Ok ( ( ) ) )
171170 . map_err ( |e| format ! ( "stub 'log': {e}" ) ) ?;
172171
173- host. func_new ( "now-millis" , |_ctx, _args, results| {
172+ host. func_new ( "now-millis" , |_ctx, _ty , _args, results| {
174173 results[ 0 ] = wasmtime:: component:: Val :: U64 ( 0 ) ;
175174 Ok ( ( ) )
176175 } )
177176 . map_err ( |e| format ! ( "stub 'now-millis': {e}" ) ) ?;
178177
179- host. func_new ( "workspace-read" , |_ctx, _args, results| {
178+ host. func_new ( "workspace-read" , |_ctx, _ty , _args, results| {
180179 results[ 0 ] = wasmtime:: component:: Val :: Option ( None ) ;
181180 Ok ( ( ) )
182181 } )
183182 . map_err ( |e| format ! ( "stub 'workspace-read': {e}" ) ) ?;
184183
185- host. func_new ( "http-request" , |_ctx, _args, results| {
184+ host. func_new ( "http-request" , |_ctx, _ty , _args, results| {
186185 results[ 0 ] = wasmtime:: component:: Val :: Result ( Err ( Some ( Box :: new (
187186 wasmtime:: component:: Val :: String ( "stub" . into ( ) ) ,
188187 ) ) ) ) ;
189188 Ok ( ( ) )
190189 } )
191190 . map_err ( |e| format ! ( "stub 'http-request': {e}" ) ) ?;
192191
193- host. func_new ( "secret-exists" , |_ctx, _args, results| {
192+ host. func_new ( "secret-exists" , |_ctx, _ty , _args, results| {
194193 results[ 0 ] = wasmtime:: component:: Val :: Bool ( false ) ;
195194 Ok ( ( ) )
196195 } )
@@ -209,7 +208,7 @@ fn instantiate_tool_component(
209208
210209 let mut linker: Linker < TestStoreData > = Linker :: new ( engine) ;
211210
212- wasmtime_wasi:: add_to_linker_sync ( & mut linker)
211+ wasmtime_wasi:: p2 :: add_to_linker_sync ( & mut linker)
213212 . map_err ( |e| format ! ( "WASI linker failed: {e}" ) ) ?;
214213
215214 // If the WIT added/removed/renamed a function, stub registration
@@ -221,7 +220,7 @@ fn instantiate_tool_component(
221220 if let Ok ( mut host) = root. instance ( interface) {
222221 stub_shared_host_functions ( & mut host) ?;
223222
224- host. func_new ( "tool-invoke" , |_ctx, _args, results| {
223+ host. func_new ( "tool-invoke" , |_ctx, _ty , _args, results| {
225224 results[ 0 ] = wasmtime:: component:: Val :: Result ( Err ( Some ( Box :: new (
226225 wasmtime:: component:: Val :: String ( "stub" . into ( ) ) ,
227226 ) ) ) ) ;
@@ -249,7 +248,7 @@ fn instantiate_channel_component(
249248
250249 let mut linker: Linker < TestStoreData > = Linker :: new ( engine) ;
251250
252- wasmtime_wasi:: add_to_linker_sync ( & mut linker)
251+ wasmtime_wasi:: p2 :: add_to_linker_sync ( & mut linker)
253252 . map_err ( |e| format ! ( "WASI linker failed: {e}" ) ) ?;
254253
255254 // Register stubs for both versioned (0.3.0+) and unversioned (pre-0.3.0) interface
@@ -261,30 +260,30 @@ fn instantiate_channel_component(
261260 ) -> Result < ( ) , String > {
262261 stub_shared_host_functions ( host) ?;
263262
264- host. func_new ( "store-attachment-data" , |_ctx, _args, results| {
263+ host. func_new ( "store-attachment-data" , |_ctx, _ty , _args, results| {
265264 results[ 0 ] = wasmtime:: component:: Val :: Result ( Ok ( None ) ) ;
266265 Ok ( ( ) )
267266 } )
268267 . map_err ( |e| format ! ( "stub 'store-attachment-data': {e}" ) ) ?;
269268
270- host. func_new ( "emit-message" , |_ctx, _args, _results| Ok ( ( ) ) )
269+ host. func_new ( "emit-message" , |_ctx, _ty , _args, _results| Ok ( ( ) ) )
271270 . map_err ( |e| format ! ( "stub 'emit-message': {e}" ) ) ?;
272271
273- host. func_new ( "workspace-write" , |_ctx, _args, results| {
272+ host. func_new ( "workspace-write" , |_ctx, _ty , _args, results| {
274273 results[ 0 ] = wasmtime:: component:: Val :: Result ( Ok ( None ) ) ;
275274 Ok ( ( ) )
276275 } )
277276 . map_err ( |e| format ! ( "stub 'workspace-write': {e}" ) ) ?;
278277
279- host. func_new ( "pairing-upsert-request" , |_ctx, _args, results| {
278+ host. func_new ( "pairing-upsert-request" , |_ctx, _ty , _args, results| {
280279 results[ 0 ] = wasmtime:: component:: Val :: Result ( Err ( Some ( Box :: new (
281280 wasmtime:: component:: Val :: String ( "stub" . into ( ) ) ,
282281 ) ) ) ) ;
283282 Ok ( ( ) )
284283 } )
285284 . map_err ( |e| format ! ( "stub 'pairing-upsert-request': {e}" ) ) ?;
286285
287- host. func_new ( "pairing-resolve-identity" , |_ctx, _args, results| {
286+ host. func_new ( "pairing-resolve-identity" , |_ctx, _ty , _args, results| {
288287 // Test stub: unknown sender — returns Ok(option::none).
289288 results[ 0 ] = wasmtime:: component:: Val :: Result ( Ok ( Some ( Box :: new (
290289 wasmtime:: component:: Val :: Option ( None ) ,
@@ -293,7 +292,7 @@ fn instantiate_channel_component(
293292 } )
294293 . map_err ( |e| format ! ( "stub 'pairing-resolve-identity': {e}" ) ) ?;
295294
296- host. func_new ( "pairing-read-allow-from" , |_ctx, _args, results| {
295+ host. func_new ( "pairing-read-allow-from" , |_ctx, _ty , _args, results| {
297296 results[ 0 ] = wasmtime:: component:: Val :: Result ( Ok ( Some ( Box :: new (
298297 wasmtime:: component:: Val :: List ( vec ! [ ] ) ,
299298 ) ) ) ) ;
0 commit comments