From c7c82501ce50f3a443eb98c94d8aaaa4e94a0252 Mon Sep 17 00:00:00 2001 From: Roman Volosatovs Date: Mon, 3 Jun 2024 13:17:03 +0200 Subject: [PATCH] feat(runtime-wasmtime): sync codec with latest spec changes Signed-off-by: Roman Volosatovs --- Cargo.lock | 26 ++++++++++++++++++++++++-- Cargo.toml | 2 +- crates/runtime-wasmtime/src/lib.rs | 12 +++++++----- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c3c22b60..c01be1b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1202,6 +1202,16 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" +[[package]] +name = "leb128-tokio" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47a57548d0fcd8bf0c9c601af2a3fdd05dac4829b82ae872e893df31f523e8ae" +dependencies = [ + "tokio", + "tokio-util", +] + [[package]] name = "libc" version = "0.2.154" @@ -2522,6 +2532,16 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "utf8-tokio" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29f6ede684629efe08c9538958d0f80a4a7475dd49f41fb102b799882098e55a" +dependencies = [ + "tokio", + "tokio-util", +] + [[package]] name = "utf8parse" version = "0.2.1" @@ -2678,12 +2698,14 @@ dependencies = [ [[package]] name = "wasm-tokio" -version = "0.1.11" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fccf07b746992fc4b8922dfe0feff98ff3aed34f4627cb96ccc3a279381dec1" +checksum = "15db3d053fd102fa738502799dd19d0c3e7645b290004dabbdc2f86830d1344c" dependencies = [ + "leb128-tokio", "tokio", "tokio-util", + "utf8-tokio", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index b55bb045..ea7c8499 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -117,7 +117,7 @@ tower = { version = "0.4", default-features = false } tracing = { version = "0.1", default-features = false } tracing-subscriber = { version = "0.3", default-features = false } url = { version = "2", default-features = false } -wasm-tokio = { version = "0.1", default-features = false } +wasm-tokio = { version = "0.4", default-features = false } wasmcloud-component-adapters = { version = "0.9", default-features = false } wasmparser = { version = "0.208", default-features = false } wasmtime = { version = "21", default-features = false } diff --git a/crates/runtime-wasmtime/src/lib.rs b/crates/runtime-wasmtime/src/lib.rs index 6a19cb4a..b64094fe 100644 --- a/crates/runtime-wasmtime/src/lib.rs +++ b/crates/runtime-wasmtime/src/lib.rs @@ -1,6 +1,5 @@ #![allow(clippy::type_complexity)] // TODO: https://github.com/wrpc/wrpc/issues/2 -use core::fmt::{self, Display}; use core::future::Future; use core::iter::zip; use core::ops::{BitOrAssign, Shl}; @@ -18,8 +17,11 @@ use tokio::try_join; use tokio_util::codec::Encoder; use tracing::{error, trace}; use tracing::{instrument, warn}; -use wasm_tokio::cm::{AsyncReadValue as _, CharEncoder}; -use wasm_tokio::{AsyncReadCore as _, CoreStringEncoder, Leb128Encoder}; +use wasm_tokio::cm::AsyncReadValue as _; +use wasm_tokio::{ + AsyncReadCore as _, AsyncReadLeb128 as _, AsyncReadUtf8 as _, CoreStringEncoder, Leb128Encoder, + Utf8Encoder, +}; use wasmtime::component::types::{self, Case, Field}; use wasmtime::component::{Linker, ResourceType, Type, Val}; use wasmtime::{AsContextMut, StoreContextMut}; @@ -168,7 +170,7 @@ where Ok(()) } (Val::Char(v), Type::Char) => { - CharEncoder.encode(*v, dst).context("failed to encode char") + Utf8Encoder.encode(*v, dst).context("failed to encode char") } (Val::String(v), Type::String) => CoreStringEncoder .encode(v.as_str(), dst) @@ -582,7 +584,7 @@ where Ok(()) } Type::Char => { - let v = r.read_char().await?; + let v = r.read_char_utf8().await?; *val = Val::Char(v); Ok(()) }