TheWaWaR opened issue #5403:
wasmtime version:
3.0.1Currently, we can use
wasmtime_wasi::WasiCtxas 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
WasiCtxcan 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
wasithave nolimitsfield, so how can weStoreLimitsto 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.1Currently, we can use
wasmtime_wasi::WasiCtxas 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
WasiCtxcan 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
wasithave nolimitsfield, so how can weStoreLimitsto limit the resource usage?
Last updated: Dec 06 2025 at 06:05 UTC