From 5ab4339c98179958b11b716b5887ecd3224666e2 Mon Sep 17 00:00:00 2001 From: Mica White Date: Wed, 29 Jul 2026 21:25:01 -0400 Subject: Support tortuise --- crates/types/src/value.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'crates/types') diff --git a/crates/types/src/value.rs b/crates/types/src/value.rs index 782cdb8..129b7c1 100644 --- a/crates/types/src/value.rs +++ b/crates/types/src/value.rs @@ -232,3 +232,43 @@ impl_conversion_for_wasmvalue! { ExternRef => RefExtern, as_ref_extern, "Return the [`ExternRef`] from a `WasmValue`, if it is one"; FuncRef => RefFunc, as_ref_func, "Return the [`FuncRef`] from a `WasmValue`, if it is one"; } + +impl From for WasmValue { + #[inline] + fn from(i: u32) -> Self { + Self::I32(i as i32) + } +} + +impl TryFrom for u32 { + type Error = (); + + #[inline] + fn try_from(value: WasmValue) -> Result { + if let WasmValue::I32(i) = value { + Ok(i as u32) + } else { + Err(()) + } + } +} + +impl From for WasmValue { + #[inline] + fn from(i: u64) -> Self { + Self::I64(i as i64) + } +} + +impl TryFrom for u64 { + type Error = (); + + #[inline] + fn try_from(value: WasmValue) -> Result { + if let WasmValue::I64(i) = value { + Ok(i as u64) + } else { + Err(()) + } + } +} -- cgit v1.3.1