From 9871ca7b1edd9e6480a10e09a1c77844531d5c9f Mon Sep 17 00:00:00 2001 From: Roman Volosatovs Date: Wed, 18 Sep 2024 10:54:14 +0200 Subject: [PATCH] chore: address clippy warnings Signed-off-by: Roman Volosatovs --- src/lib.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 788e958..6df2eee 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,7 +6,7 @@ use wasi_preview1_component_adapter_provider::{ WASI_SNAPSHOT_PREVIEW1_ADAPTER_NAME, WASI_SNAPSHOT_PREVIEW1_REACTOR_ADAPTER, }; use wasmtime::component::{Component, Linker, Resource, ResourceTable, Type, TypedFunc, Val}; -use wasmtime::{Engine, Store}; +use wasmtime::{AsContext as _, AsContextMut as _, Engine, Store}; use wasmtime_wasi::{WasiCtx, WasiCtxBuilder, WasiView}; use wasmtime_wasi_http::types::HostIncomingRequest; use wasmtime_wasi_http::{WasiHttpCtx, WasiHttpView}; @@ -182,25 +182,27 @@ pub struct Func<'a> { } impl Func<'_> { + #[must_use] pub fn params(&self) -> Box<[Type]> { - self.func.params(&self.store) + self.func.params(self.store.as_context()) } + #[must_use] pub fn results(&self) -> Box<[Type]> { - self.func.results(&self.store) + self.func.results(self.store.as_context()) } pub fn call(&mut self, params: &[Val], results: &mut [Val]) -> anyhow::Result<()> { self.func - .call(&mut self.store, params, results) + .call(self.store.as_context_mut(), params, results) .context("failed to call function")?; self.func - .post_return(&mut self.store) + .post_return(self.store.as_context_mut()) .context("failed to invoke `post-return`") } pub fn store(&mut self) -> &mut Store { - &mut self.store + self.store } } @@ -265,9 +267,9 @@ impl Instance { } pub fn instantiate(Config { engine, wasm }: Config) -> anyhow::Result { - let wasm = if wasmparser::Parser::is_core_wasm(&wasm) { + let wasm = if wasmparser::Parser::is_core_wasm(wasm) { let wasm = wit_component::ComponentEncoder::default() - .module(&wasm) + .module(wasm) .context("failed to set core component module")? .adapter( WASI_SNAPSHOT_PREVIEW1_ADAPTER_NAME,