@@ -23,26 +23,24 @@ use crate::{
23
23
wasi_2023_10_18, wasi_2023_11_10, InstanceState , OutboundHttpFactor , SelfRequestOrigin ,
24
24
} ;
25
25
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 < ' _ > >
30
31
where
31
- F : Fn ( & mut T ) -> WasiHttpImpl < WasiHttpImplInner > ,
32
+ C : spin_factors :: InitContext < OutboundHttpFactor > ,
32
33
{
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) ;
38
35
WasiHttpImpl ( IoImpl ( WasiHttpImplInner { state, table } ) )
39
- } ) ;
36
+ }
37
+ let get_http = get_http :: < C > as fn ( & mut C :: StoreData ) -> WasiHttpImpl < WasiHttpImplInner < ' _ > > ;
40
38
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 ) ?;
43
41
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 ) ?;
46
44
47
45
Ok ( ( ) )
48
46
}
0 commit comments