@@ -23,26 +23,24 @@ use crate::{
2323 wasi_2023_10_18, wasi_2023_11_10, InstanceState , OutboundHttpFactor , SelfRequestOrigin ,
2424} ;
2525
26- pub ( crate ) fn add_to_linker < T : Send + ' static > (
27- ctx : & mut spin_factors:: InitContext < T , OutboundHttpFactor > ,
28- ) -> anyhow:: Result < ( ) > {
29- fn type_annotate < T , F > ( f : F ) -> F
26+ pub ( crate ) fn add_to_linker < C > ( ctx : & mut C ) -> anyhow:: Result < ( ) >
27+ where
28+ C : spin_factors:: InitContext < OutboundHttpFactor > ,
29+ {
30+ fn get_http < C > ( store : & mut C :: StoreData ) -> WasiHttpImpl < WasiHttpImplInner < ' _ > >
3031 where
31- F : Fn ( & mut T ) -> WasiHttpImpl < WasiHttpImplInner > ,
32+ C : spin_factors :: InitContext < OutboundHttpFactor > ,
3233 {
33- f
34- }
35- let get_data_with_table = ctx. get_data_with_table_fn ( ) ;
36- let closure = type_annotate ( move |data| {
37- let ( state, table) = get_data_with_table ( data) ;
34+ let ( state, table) = C :: get_data_with_table ( store) ;
3835 WasiHttpImpl ( IoImpl ( WasiHttpImplInner { state, table } ) )
39- } ) ;
36+ }
37+ let get_http = get_http :: < C > as fn ( & mut C :: StoreData ) -> WasiHttpImpl < WasiHttpImplInner < ' _ > > ;
4038 let linker = ctx. linker ( ) ;
41- wasmtime_wasi_http:: bindings:: http:: outgoing_handler:: add_to_linker_get_host ( linker, closure ) ?;
42- wasmtime_wasi_http:: bindings:: http:: types:: add_to_linker_get_host ( linker, closure ) ?;
39+ wasmtime_wasi_http:: bindings:: http:: outgoing_handler:: add_to_linker_get_host ( linker, get_http ) ?;
40+ wasmtime_wasi_http:: bindings:: http:: types:: add_to_linker_get_host ( linker, get_http ) ?;
4341
44- wasi_2023_10_18:: add_to_linker ( linker, closure ) ?;
45- wasi_2023_11_10:: add_to_linker ( linker, closure ) ?;
42+ wasi_2023_10_18:: add_to_linker ( linker, get_http ) ?;
43+ wasi_2023_11_10:: add_to_linker ( linker, get_http ) ?;
4644
4745 Ok ( ( ) )
4846}
0 commit comments