@@ -673,14 +673,16 @@ enum FdWrite {
673
673
/// Adds asynchronous versions of all WASIp1 functions to the
674
674
/// [`wasmtime::Linker`] provided.
675
675
///
676
- /// This method will add WASIp1 functions to `linker`. The `f` closure provided
677
- /// is used to project from the `T` state that `Linker` is associated with to a
678
- /// [`WasiP1Ctx`]. If `T ` is `WasiP1Ctx` itself then this is the identity
679
- /// closure, but otherwise it must project out the field where `WasiP1Ctx` is
680
- /// stored within `T` .
676
+ /// This method will add WASIp1 functions to `linker`. Access to [`WasiP1Ctx`]
677
+ /// is provided with `f` by projecting from the store-local state of `T` to
678
+ /// [`WasiP1Ctx`]. The closure `f ` is invoked every time a WASIp1 function is
679
+ /// called to get access to [`WASIp1`] from `T`. The returned [ `WasiP1Ctx`] is
680
+ /// used to implement I/O and controls what each function will return .
681
681
///
682
- /// The state provided by `f` is used to implement all WASIp1 functions and
683
- /// provides configuration to know what to return.
682
+ /// It's recommended that [`WasiP1Ctx`] is stored as a field in `T` or that `T =
683
+ /// WasiP1Ctx` itself. The closure `f` should be a small projection (e.g. `&mut
684
+ /// arg.field`) or something otherwise "small" as it will be executed every time
685
+ /// a WASI call is made.
684
686
///
685
687
/// Note that this function is intended for use with
686
688
/// [`Config::async_support(true)`]. If you're looking for a synchronous version
@@ -745,14 +747,16 @@ pub fn add_to_linker_async<T: Send>(
745
747
/// Adds synchronous versions of all WASIp1 functions to the
746
748
/// [`wasmtime::Linker`] provided.
747
749
///
748
- /// This method will add WASIp1 functions to `linker`. The `f` closure provided
749
- /// is used to project from the `T` state that `Linker` is associated with to a
750
- /// [`WasiP1Ctx`]. If `T ` is `WasiP1Ctx` itself then this is the identity
751
- /// closure, but otherwise it must project out the field where `WasiP1Ctx` is
752
- /// stored within `T` .
750
+ /// This method will add WASIp1 functions to `linker`. Access to [`WasiP1Ctx`]
751
+ /// is provided with `f` by projecting from the store-local state of `T` to
752
+ /// [`WasiP1Ctx`]. The closure `f ` is invoked every time a WASIp1 function is
753
+ /// called to get access to [`WASIp1`] from `T`. The returned [ `WasiP1Ctx`] is
754
+ /// used to implement I/O and controls what each function will return .
753
755
///
754
- /// The state provided by `f` is used to implement all WASIp1 functions and
755
- /// provides configuration to know what to return.
756
+ /// It's recommended that [`WasiP1Ctx`] is stored as a field in `T` or that `T =
757
+ /// WasiP1Ctx` itself. The closure `f` should be a small projection (e.g. `&mut
758
+ /// arg.field`) or something otherwise "small" as it will be executed every time
759
+ /// a WASI call is made.
756
760
///
757
761
/// Note that this function is intended for use with
758
762
/// [`Config::async_support(false)`]. If you're looking for a synchronous version
0 commit comments