TheWaWaR opened issue #5403:
wasmtime version:
3.0.1
Currently, we can use
wasmtime_wasi::WasiCtx
as follow:let mut linker: Linker<WasiCtx> = Linker::new(&engine); wasmtime_wasi::add_to_linker(&mut linker, |s| s)?; let wasi = WasiCtxBuilder::new().build(); let mut store = Store::new(engine, wasi);
The problem here is the
WasiCtx
can only be used as concrete store state and can't compose with other fields.From the example we can use like this:
store.limiter(move |state| &mut state.limits);
But now
wasit
have nolimits
field, so how can weStoreLimits
to limit the resource usage?
bjorn3 commented on issue #5403:
I believe you can do
struct State { limits: MyResourceLimiter, wasi: WasiCtx, } let mut linker: Linker<WasiCtx> = Linker::new(&engine); wasmtime_wasi::add_to_linker(&mut linker, |state| &mut state.wasi)?; let wasi = WasiCtxBuilder::new().build(); let limits = todo!(); let mut store = Store::new(engine, State { limits, wasi }); store.limiter(move |state| &mut state.limits);
TheWaWaR commented on issue #5403:
Oh, there it is.
Thanks very much!
TheWaWaR closed issue #5403:
wasmtime version:
3.0.1
Currently, we can use
wasmtime_wasi::WasiCtx
as follow:let mut linker: Linker<WasiCtx> = Linker::new(&engine); wasmtime_wasi::add_to_linker(&mut linker, |s| s)?; let wasi = WasiCtxBuilder::new().build(); let mut store = Store::new(engine, wasi);
The problem here is the
WasiCtx
can only be used as concrete store state and can't compose with other fields.From the example we can use like this:
store.limiter(move |state| &mut state.limits);
But now
wasit
have nolimits
field, so how can weStoreLimits
to limit the resource usage?
Last updated: Nov 22 2024 at 17:03 UTC