27
27
//!
28
28
//! All `bindgen!`-generated `Host` traits are implemented in terms of a
29
29
//! [`WasiHttpView`] trait which provides basic access to [`WasiHttpCtx`],
30
- //! configuration for WASI HTTP, and a [`wasmtime_wasi::ResourceTable`], the
30
+ //! configuration for WASI HTTP, and a [`wasmtime_wasi::p2:: ResourceTable`], the
31
31
//! state for all host-defined component model resources.
32
32
//!
33
33
//! The [`WasiHttpView`] trait additionally offers a few other configuration
53
53
//! `wasi:http/proxy` together
54
54
//! * Use [`add_only_http_to_linker_async`] to add only HTTP interfaces but
55
55
//! no others. This is useful when working with
56
- //! [`wasmtime_wasi::add_to_linker_async`] for example.
56
+ //! [`wasmtime_wasi::p2:: add_to_linker_async`] for example.
57
57
//! * Add individual interfaces such as with the
58
58
//! [`bindings::http::outgoing_handler::add_to_linker_get_host`] function.
59
59
//! 3. Use [`ProxyPre`](bindings::ProxyPre) to pre-instantiate a component
71
71
//! use tokio::net::TcpListener;
72
72
//! use wasmtime::component::{Component, Linker, ResourceTable};
73
73
//! use wasmtime::{Config, Engine, Result, Store};
74
- //! use wasmtime_wasi::{IoView, WasiCtx, WasiCtxBuilder, WasiView};
74
+ //! use wasmtime_wasi::p2:: {IoView, WasiCtx, WasiCtxBuilder, WasiView};
75
75
//! use wasmtime_wasi_http::bindings::ProxyPre;
76
76
//! use wasmtime_wasi_http::bindings::http::types::Scheme;
77
77
//! use wasmtime_wasi_http::body::HyperOutgoingBody;
@@ -237,7 +237,7 @@ pub use crate::types::{
237
237
WasiHttpCtx , WasiHttpImpl , WasiHttpView , DEFAULT_OUTGOING_BODY_BUFFER_CHUNKS ,
238
238
DEFAULT_OUTGOING_BODY_CHUNK_SIZE ,
239
239
} ;
240
- use wasmtime_wasi:: IoImpl ;
240
+ use wasmtime_wasi:: p2 :: IoImpl ;
241
241
/// Add all of the `wasi:http/proxy` world's interfaces to a [`wasmtime::component::Linker`].
242
242
///
243
243
/// This function will add the `async` variant of all interfaces into the
@@ -252,7 +252,7 @@ use wasmtime_wasi::IoImpl;
252
252
/// ```
253
253
/// use wasmtime::{Engine, Result, Config};
254
254
/// use wasmtime::component::{ResourceTable, Linker};
255
- /// use wasmtime_wasi::{IoView, WasiCtx, WasiView};
255
+ /// use wasmtime_wasi::p2:: {IoView, WasiCtx, WasiView};
256
256
/// use wasmtime_wasi_http::{WasiHttpCtx, WasiHttpView};
257
257
///
258
258
/// fn main() -> Result<()> {
@@ -285,20 +285,21 @@ use wasmtime_wasi::IoImpl;
285
285
/// ```
286
286
pub fn add_to_linker_async < T > ( l : & mut wasmtime:: component:: Linker < T > ) -> anyhow:: Result < ( ) >
287
287
where
288
- T : WasiHttpView + wasmtime_wasi:: WasiView ,
288
+ T : WasiHttpView + wasmtime_wasi:: p2 :: WasiView ,
289
289
{
290
- let io_closure = type_annotate_io :: < T , _ > ( |t| wasmtime_wasi:: IoImpl ( t) ) ;
291
- wasmtime_wasi:: bindings:: io:: poll:: add_to_linker_get_host ( l, io_closure) ?;
292
- wasmtime_wasi:: bindings:: io:: error:: add_to_linker_get_host ( l, io_closure) ?;
293
- wasmtime_wasi:: bindings:: io:: streams:: add_to_linker_get_host ( l, io_closure) ?;
290
+ let io_closure = type_annotate_io :: < T , _ > ( |t| wasmtime_wasi:: p2 :: IoImpl ( t) ) ;
291
+ wasmtime_wasi:: p2 :: bindings:: io:: poll:: add_to_linker_get_host ( l, io_closure) ?;
292
+ wasmtime_wasi:: p2 :: bindings:: io:: error:: add_to_linker_get_host ( l, io_closure) ?;
293
+ wasmtime_wasi:: p2 :: bindings:: io:: streams:: add_to_linker_get_host ( l, io_closure) ?;
294
294
295
- let closure = type_annotate_wasi :: < T , _ > ( |t| wasmtime_wasi:: WasiImpl ( wasmtime_wasi:: IoImpl ( t) ) ) ;
296
- wasmtime_wasi:: bindings:: clocks:: wall_clock:: add_to_linker_get_host ( l, closure) ?;
297
- wasmtime_wasi:: bindings:: clocks:: monotonic_clock:: add_to_linker_get_host ( l, closure) ?;
298
- wasmtime_wasi:: bindings:: cli:: stdin:: add_to_linker_get_host ( l, closure) ?;
299
- wasmtime_wasi:: bindings:: cli:: stdout:: add_to_linker_get_host ( l, closure) ?;
300
- wasmtime_wasi:: bindings:: cli:: stderr:: add_to_linker_get_host ( l, closure) ?;
301
- wasmtime_wasi:: bindings:: random:: random:: add_to_linker_get_host ( l, closure) ?;
295
+ let closure =
296
+ type_annotate_wasi :: < T , _ > ( |t| wasmtime_wasi:: p2:: WasiImpl ( wasmtime_wasi:: p2:: IoImpl ( t) ) ) ;
297
+ wasmtime_wasi:: p2:: bindings:: clocks:: wall_clock:: add_to_linker_get_host ( l, closure) ?;
298
+ wasmtime_wasi:: p2:: bindings:: clocks:: monotonic_clock:: add_to_linker_get_host ( l, closure) ?;
299
+ wasmtime_wasi:: p2:: bindings:: cli:: stdin:: add_to_linker_get_host ( l, closure) ?;
300
+ wasmtime_wasi:: p2:: bindings:: cli:: stdout:: add_to_linker_get_host ( l, closure) ?;
301
+ wasmtime_wasi:: p2:: bindings:: cli:: stderr:: add_to_linker_get_host ( l, closure) ?;
302
+ wasmtime_wasi:: p2:: bindings:: random:: random:: add_to_linker_get_host ( l, closure) ?;
302
303
303
304
add_only_http_to_linker_async ( l)
304
305
}
@@ -313,21 +314,21 @@ where
313
314
}
314
315
fn type_annotate_wasi < T , F > ( val : F ) -> F
315
316
where
316
- F : Fn ( & mut T ) -> wasmtime_wasi:: WasiImpl < & mut T > ,
317
+ F : Fn ( & mut T ) -> wasmtime_wasi:: p2 :: WasiImpl < & mut T > ,
317
318
{
318
319
val
319
320
}
320
321
fn type_annotate_io < T , F > ( val : F ) -> F
321
322
where
322
- F : Fn ( & mut T ) -> wasmtime_wasi:: IoImpl < & mut T > ,
323
+ F : Fn ( & mut T ) -> wasmtime_wasi:: p2 :: IoImpl < & mut T > ,
323
324
{
324
325
val
325
326
}
326
327
327
328
/// A slimmed down version of [`add_to_linker_async`] which only adds
328
329
/// `wasi:http` interfaces to the linker.
329
330
///
330
- /// This is useful when using [`wasmtime_wasi::add_to_linker_async`] for
331
+ /// This is useful when using [`wasmtime_wasi::p2:: add_to_linker_async`] for
331
332
/// example to avoid re-adding the same interfaces twice.
332
333
pub fn add_only_http_to_linker_async < T > (
333
334
l : & mut wasmtime:: component:: Linker < T > ,
@@ -353,7 +354,7 @@ where
353
354
/// ```
354
355
/// use wasmtime::{Engine, Result, Config};
355
356
/// use wasmtime::component::{ResourceTable, Linker};
356
- /// use wasmtime_wasi::{IoView, WasiCtx, WasiView};
357
+ /// use wasmtime_wasi::p2:: {IoView, WasiCtx, WasiView};
357
358
/// use wasmtime_wasi_http::{WasiHttpCtx, WasiHttpView};
358
359
///
359
360
/// fn main() -> Result<()> {
@@ -384,24 +385,25 @@ where
384
385
/// ```
385
386
pub fn add_to_linker_sync < T > ( l : & mut wasmtime:: component:: Linker < T > ) -> anyhow:: Result < ( ) >
386
387
where
387
- T : WasiHttpView + wasmtime_wasi:: WasiView ,
388
+ T : WasiHttpView + wasmtime_wasi:: p2 :: WasiView ,
388
389
{
389
- let io_closure = type_annotate_io :: < T , _ > ( |t| wasmtime_wasi:: IoImpl ( t) ) ;
390
+ let io_closure = type_annotate_io :: < T , _ > ( |t| wasmtime_wasi:: p2 :: IoImpl ( t) ) ;
390
391
// For the sync linker, use the definitions of poll and streams from the
391
- // wasmtime_wasi::bindings::sync space because those are defined using in_tokio.
392
- wasmtime_wasi:: bindings:: sync:: io:: poll:: add_to_linker_get_host ( l, io_closure) ?;
393
- wasmtime_wasi:: bindings:: sync:: io:: streams:: add_to_linker_get_host ( l, io_closure) ?;
392
+ // wasmtime_wasi::p2:: bindings::sync space because those are defined using in_tokio.
393
+ wasmtime_wasi:: p2 :: bindings:: sync:: io:: poll:: add_to_linker_get_host ( l, io_closure) ?;
394
+ wasmtime_wasi:: p2 :: bindings:: sync:: io:: streams:: add_to_linker_get_host ( l, io_closure) ?;
394
395
// The error interface in the wasmtime_wasi is synchronous
395
- wasmtime_wasi:: bindings:: io:: error:: add_to_linker_get_host ( l, io_closure) ?;
396
+ wasmtime_wasi:: p2 :: bindings:: io:: error:: add_to_linker_get_host ( l, io_closure) ?;
396
397
397
- let closure = type_annotate_wasi :: < T , _ > ( |t| wasmtime_wasi:: WasiImpl ( wasmtime_wasi:: IoImpl ( t) ) ) ;
398
+ let closure =
399
+ type_annotate_wasi :: < T , _ > ( |t| wasmtime_wasi:: p2:: WasiImpl ( wasmtime_wasi:: p2:: IoImpl ( t) ) ) ;
398
400
399
- wasmtime_wasi:: bindings:: clocks:: wall_clock:: add_to_linker_get_host ( l, closure) ?;
400
- wasmtime_wasi:: bindings:: clocks:: monotonic_clock:: add_to_linker_get_host ( l, closure) ?;
401
- wasmtime_wasi:: bindings:: cli:: stdin:: add_to_linker_get_host ( l, closure) ?;
402
- wasmtime_wasi:: bindings:: cli:: stdout:: add_to_linker_get_host ( l, closure) ?;
403
- wasmtime_wasi:: bindings:: cli:: stderr:: add_to_linker_get_host ( l, closure) ?;
404
- wasmtime_wasi:: bindings:: random:: random:: add_to_linker_get_host ( l, closure) ?;
401
+ wasmtime_wasi:: p2 :: bindings:: clocks:: wall_clock:: add_to_linker_get_host ( l, closure) ?;
402
+ wasmtime_wasi:: p2 :: bindings:: clocks:: monotonic_clock:: add_to_linker_get_host ( l, closure) ?;
403
+ wasmtime_wasi:: p2 :: bindings:: cli:: stdin:: add_to_linker_get_host ( l, closure) ?;
404
+ wasmtime_wasi:: p2 :: bindings:: cli:: stdout:: add_to_linker_get_host ( l, closure) ?;
405
+ wasmtime_wasi:: p2 :: bindings:: cli:: stderr:: add_to_linker_get_host ( l, closure) ?;
406
+ wasmtime_wasi:: p2 :: bindings:: random:: random:: add_to_linker_get_host ( l, closure) ?;
405
407
406
408
add_only_http_to_linker_sync ( l) ?;
407
409
@@ -411,7 +413,7 @@ where
411
413
/// A slimmed down version of [`add_to_linker_sync`] which only adds
412
414
/// `wasi:http` interfaces to the linker.
413
415
///
414
- /// This is useful when using [`wasmtime_wasi::add_to_linker_sync`] for
416
+ /// This is useful when using [`wasmtime_wasi::p2:: add_to_linker_sync`] for
415
417
/// example to avoid re-adding the same interfaces twice.
416
418
pub fn add_only_http_to_linker_sync < T > ( l : & mut wasmtime:: component:: Linker < T > ) -> anyhow:: Result < ( ) >
417
419
where
0 commit comments