From 2ba52a1c9d303bca84b386427f5d80d3b231ba51 Mon Sep 17 00:00:00 2001 From: T0mstone Date: Sat, 16 Aug 2025 22:16:35 +0200 Subject: [PATCH 1/4] Update to wasm_runtime_layer v0.6 (breaking) --- Cargo.toml | 4 ++-- src/func.rs | 2 +- src/lib.rs | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0ad6101..ab19222 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wasm_component_layer" -version = "0.1.18" +version = "0.2.0" edition = "2021" license = "Apache-2.0" repository = "https://github.com/DouglasDwyer/wasm_component_layer" @@ -18,7 +18,7 @@ ref-cast = { version = "1.0.23", default-features = false } semver = { version = "1.0.23", default-features = false } serde = { version = "1.0.204", optional = true, default-features = false, features = [ "derive", "rc" ] } slab = { version = "0.4.9", default-features = false } -wasm_runtime_layer = { version = ">=0.4.0", default-features = false } +wasm_runtime_layer = { version = "0.6.0", default-features = false } wasmtime-environ = { version = "18.0.1", features = [ "component-model" ] } wit-component = { version = "0.19.0", default-features = false } wit-parser = { version = "0.13.0", default-features = false } diff --git a/src/func.rs b/src/func.rs index 0090ea2..d41b3f3 100644 --- a/src/func.rs +++ b/src/func.rs @@ -1395,7 +1395,7 @@ type FunctionBacking = type FunctionBackingKeyPair = (Arc, Arc>); /// A vector for functions that automatically drops items when the references are dropped. -pub(crate) struct FuncVec { +pub(crate) struct FuncVec { /// The functions stored in the vector. functions: Vec>, } diff --git a/src/lib.rs b/src/lib.rs index 973a7f2..a1c68bf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -184,7 +184,7 @@ impl Component { modules.insert( id, ModuleTranslation { - module: Module::new(engine, std::io::Cursor::new(module.wasm))?, + module: Module::new(engine, module.wasm)?, translation: module.module, }, ); @@ -1966,7 +1966,7 @@ struct ComponentExport { /// the Wasm bytes into a valid module artifact). /// /// Spec: -pub struct Store { +pub struct Store { /// The backing implementation. inner: wasm_runtime_layer::Store, E>, } @@ -2030,7 +2030,7 @@ impl Store { /// /// This type is suitable for [`AsContext`] trait bounds on methods if desired. /// For more information, see [`Store`]. -pub struct StoreContext<'a, T: 'a, E: backend::WasmEngine> { +pub struct StoreContext<'a, T: 'static, E: backend::WasmEngine> { /// The backing implementation. inner: wasm_runtime_layer::StoreContext<'a, StoreInner, E>, } @@ -2053,7 +2053,7 @@ impl<'a, T: 'a, E: backend::WasmEngine> StoreContext<'a, T, E> { /// /// This type is suitable for [`AsContextMut`] or [`AsContext`] trait bounds on methods if desired. /// For more information, see [`Store`]. -pub struct StoreContextMut<'a, T: 'a, E: backend::WasmEngine> { +pub struct StoreContextMut<'a, T: 'static, E: backend::WasmEngine> { /// The backing implementation. inner: wasm_runtime_layer::StoreContextMut<'a, StoreInner, E>, } @@ -2085,7 +2085,7 @@ pub trait AsContext { type Engine: backend::WasmEngine; /// The user state associated with the [`Store`], aka the `T` in `Store`. - type UserState; + type UserState: 'static; /// Returns the store context that this type provides access to. fn as_context(&self) -> StoreContext; @@ -2176,7 +2176,7 @@ impl<'a, T: 'a, E: backend::WasmEngine> AsContextMut for StoreContextMut<'a, T, } /// Holds the inner mutable state for a component model implementation. -struct StoreInner { +struct StoreInner { /// The unique ID of this store. pub id: u64, /// The consumer's custom data. From caba87db4dee90a54d61294037bc037e07d9773e Mon Sep 17 00:00:00 2001 From: T0mstone Date: Sat, 16 Aug 2025 22:41:23 +0200 Subject: [PATCH 2/4] Update dev-dependencies --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ab19222..e792ec1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,5 +27,5 @@ wit-parser = { version = "0.13.0", default-features = false } serde = [ "dep:serde", "semver/serde" ] [dev-dependencies] -wasmi = "0.31.1" -wasmi_runtime_layer = "0.31.0" \ No newline at end of file +wasmi = "0.48.0" +wasmi_runtime_layer = "0.48.0" \ No newline at end of file From 795f95b9c7cac9c432ebb58109621262dd695cce Mon Sep 17 00:00:00 2001 From: T0mstone Date: Sat, 16 Aug 2025 22:41:50 +0200 Subject: [PATCH 3/4] Patch wasm_runtime_layer to current master ...because apparently the version 0.6.0 published to crates.io is just broken --- Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index e792ec1..a4c6eb7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,9 @@ wasmtime-environ = { version = "18.0.1", features = [ "component-model" ] } wit-component = { version = "0.19.0", default-features = false } wit-parser = { version = "0.13.0", default-features = false } +[patch.crates-io] +wasm_runtime_layer = { git = "https://github.com/DouglasDwyer/wasm_runtime_layer", rev = "efbea9e92e82d6fd3e97af9386e5f7517c64db12" } + [features] serde = [ "dep:serde", "semver/serde" ] From 93ceadff237da5c2b857457e11f24a9e70359eb9 Mon Sep 17 00:00:00 2001 From: T0mstone Date: Sat, 16 Aug 2025 22:45:58 +0200 Subject: [PATCH 4/4] Fix Rust 1.89 warnings --- src/lib.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index a1c68bf..2e97803 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2088,13 +2088,13 @@ pub trait AsContext { type UserState: 'static; /// Returns the store context that this type provides access to. - fn as_context(&self) -> StoreContext; + fn as_context(&self) -> StoreContext<'_, Self::UserState, Self::Engine>; } /// A trait used to get exclusive access to a [`Store`]. pub trait AsContextMut: AsContext { /// Returns the store context that this type provides access to. - fn as_context_mut(&mut self) -> StoreContextMut; + fn as_context_mut(&mut self) -> StoreContextMut<'_, Self::UserState, Self::Engine>; } impl AsContext for Store { @@ -2102,7 +2102,7 @@ impl AsContext for Store { type UserState = T; - fn as_context(&self) -> StoreContext { + fn as_context(&self) -> StoreContext<'_, Self::UserState, Self::Engine> { StoreContext { inner: wasm_runtime_layer::AsContext::as_context(&self.inner), } @@ -2110,7 +2110,7 @@ impl AsContext for Store { } impl AsContextMut for Store { - fn as_context_mut(&mut self) -> StoreContextMut { + fn as_context_mut(&mut self) -> StoreContextMut<'_, Self::UserState, Self::Engine> { StoreContextMut { inner: wasm_runtime_layer::AsContextMut::as_context_mut(&mut self.inner), } @@ -2122,7 +2122,7 @@ impl AsContext for &T { type UserState = T::UserState; - fn as_context(&self) -> StoreContext { + fn as_context(&self) -> StoreContext<'_, Self::UserState, Self::Engine> { (**self).as_context() } } @@ -2132,13 +2132,13 @@ impl AsContext for &mut T { type UserState = T::UserState; - fn as_context(&self) -> StoreContext { + fn as_context(&self) -> StoreContext<'_, Self::UserState, Self::Engine> { (**self).as_context() } } impl AsContextMut for &mut T { - fn as_context_mut(&mut self) -> StoreContextMut { + fn as_context_mut(&mut self) -> StoreContextMut<'_, Self::UserState, Self::Engine> { (**self).as_context_mut() } } @@ -2148,7 +2148,7 @@ impl<'a, T: 'a, E: backend::WasmEngine> AsContext for StoreContext<'a, T, E> { type UserState = T; - fn as_context(&self) -> StoreContext { + fn as_context(&self) -> StoreContext<'_, Self::UserState, Self::Engine> { StoreContext { inner: wasm_runtime_layer::AsContext::as_context(&self.inner), } @@ -2160,7 +2160,7 @@ impl<'a, T: 'a, E: backend::WasmEngine> AsContext for StoreContextMut<'a, T, E> type UserState = T; - fn as_context(&self) -> StoreContext { + fn as_context(&self) -> StoreContext<'_, Self::UserState, Self::Engine> { StoreContext { inner: wasm_runtime_layer::AsContext::as_context(&self.inner), } @@ -2168,7 +2168,7 @@ impl<'a, T: 'a, E: backend::WasmEngine> AsContext for StoreContextMut<'a, T, E> } impl<'a, T: 'a, E: backend::WasmEngine> AsContextMut for StoreContextMut<'a, T, E> { - fn as_context_mut(&mut self) -> StoreContextMut { + fn as_context_mut(&mut self) -> StoreContextMut<'_, Self::UserState, Self::Engine> { StoreContextMut { inner: wasm_runtime_layer::AsContextMut::as_context_mut(&mut self.inner), }