diff --git a/Cargo.lock b/Cargo.lock index e5d2d394..6f24acf0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3572,7 +3572,7 @@ dependencies = [ [[package]] name = "wit-bindgen-wrpc" -version = "0.4.4" +version = "0.4.5" dependencies = [ "anyhow", "bitflags 2.6.0", @@ -3600,7 +3600,7 @@ dependencies = [ [[package]] name = "wit-bindgen-wrpc-rust" -version = "0.4.4" +version = "0.4.5" dependencies = [ "anyhow", "clap", @@ -3616,7 +3616,7 @@ dependencies = [ [[package]] name = "wit-bindgen-wrpc-rust-macro" -version = "0.4.4" +version = "0.4.5" dependencies = [ "anyhow", "prettyplease", @@ -3748,7 +3748,7 @@ dependencies = [ [[package]] name = "wrpc-transport" -version = "0.26.2" +version = "0.26.3" dependencies = [ "anyhow", "bytes", diff --git a/Cargo.toml b/Cargo.toml index a0f5c810..44d254f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -128,16 +128,16 @@ wasmtime = { version = "22", default-features = false } wasmtime-wasi = { version = "22", default-features = false } wit-bindgen = { version = "0.27", default-features = false } wit-bindgen-core = { version = "0.27", default-features = false } -wit-bindgen-wrpc = { version = "0.4.4", default-features = false, path = "./crates/wit-bindgen" } +wit-bindgen-wrpc = { version = "0.4.5", default-features = false, path = "./crates/wit-bindgen" } wit-bindgen-wrpc-go = { version = "0.2", default-features = false, path = "./crates/wit-bindgen-go" } -wit-bindgen-wrpc-rust = { version = "0.4.4", default-features = false, path = "./crates/wit-bindgen-rust" } -wit-bindgen-wrpc-rust-macro = { version = "0.4.4", default-features = false, path = "./crates/wit-bindgen-rust-macro" } +wit-bindgen-wrpc-rust = { version = "0.4.5", default-features = false, path = "./crates/wit-bindgen-rust" } +wit-bindgen-wrpc-rust-macro = { version = "0.4.5", default-features = false, path = "./crates/wit-bindgen-rust-macro" } wit-component = { version = "0.212", default-features = false } wit-parser = { version = "0.212", default-features = false } wrpc-cli = { version = "0.2", path = "./crates/cli", default-features = false } wrpc-introspect = { version = "0.1", default-features = false, path = "./crates/introspect" } wrpc-runtime-wasmtime = { version = "0.19", path = "./crates/runtime-wasmtime", default-features = false } -wrpc-transport = { version = "0.26", path = "./crates/transport", default-features = false } +wrpc-transport = { version = "0.26.3", path = "./crates/transport", default-features = false } wrpc-transport-nats = { version = "0.22", path = "./crates/transport-nats", default-features = false } wrpc-transport-quic = { version = "0.1", path = "./crates/transport-quic", default-features = false } wrpc-wasmtime-nats-cli = { version = "0.3", path = "./crates/wasmtime-nats-cli", default-features = false } diff --git a/crates/transport/Cargo.toml b/crates/transport/Cargo.toml index 730e0b69..2795a8f8 100644 --- a/crates/transport/Cargo.toml +++ b/crates/transport/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wrpc-transport" -version = "0.26.2" +version = "0.26.3" description = "wRPC core transport functionality" authors.workspace = true diff --git a/crates/transport/src/lib.rs b/crates/transport/src/lib.rs index d9a42fcc..f698822a 100644 --- a/crates/transport/src/lib.rs +++ b/crates/transport/src/lib.rs @@ -282,21 +282,16 @@ pub trait Serve: Sync { Item = anyhow::Result<( Self::Context, Params, - Option< - impl Future> + Sync + Send + Unpin + 'static, - >, - impl FnOnce( - Results, - ) - -> Pin> + Sync + Send>>, + Option> + Send + Unpin + 'static>, + impl FnOnce(Results) -> Pin> + Send>>, )>, > + Send + 'static, >, > + Send where - Params: TupleDecode + Send + Sync + 'static, - Results: TupleEncode + Send + Sync + 'static, + Params: TupleDecode + Send + 'static, + Results: TupleEncode + Send + 'static, ::Error: std::error::Error + Send + Sync + 'static, >::Error: @@ -368,13 +363,7 @@ mod tests { #[allow(clippy::manual_async_fn)] fn invoke_values_send() -> impl Future< Output = anyhow::Result<( - Pin< - Box< - dyn Stream + Send + Sync>>>> - + Send - + Sync, - >, - >, + Pin + Send>>>> + Send>>, )>, > + Send where @@ -404,8 +393,7 @@ mod tests { i.invoke(cx, "foo", "bar", Bytes::default(), &paths).await } - async fn call_invoke_async( - ) -> anyhow::Result<(Pin + Send + Sync>>,)> + async fn call_invoke_async() -> anyhow::Result<(Pin + Send>>,)> where T: Invoke + Default, { diff --git a/crates/transport/src/value.rs b/crates/transport/src/value.rs index 2459c9a3..d41c1c12 100644 --- a/crates/transport/src/value.rs +++ b/crates/transport/src/value.rs @@ -156,12 +156,8 @@ impl ResourceOwn { } pub type DeferredFn = Box< - dyn FnOnce( - Arc, - Vec, - ) -> Pin> + Send + Sync>> - + Send - + Sync, + dyn FnOnce(Arc, Vec) -> Pin> + Send>> + + Send, >; pub trait Deferred { @@ -325,7 +321,7 @@ where } pub trait Encode: Sized { - type Encoder: tokio_util::codec::Encoder + Deferred + Default + Send + Sync; + type Encoder: tokio_util::codec::Encoder + Deferred + Default + Send; #[instrument(level = "trace", skip(self, enc))] fn encode( @@ -752,9 +748,9 @@ where impl Decode for Vec where - T: Decode + Send + Sync, + T: Decode + Send, T::ListDecoder: Deferred + Send, - R: crate::Index + Send + Sync + 'static, + R: crate::Index + Send + 'static, { type Decoder = T::ListDecoder; type ListDecoder = ListDecoder; @@ -1119,7 +1115,7 @@ impl Deferred for CoreVecDecoder> { } } -impl Decode for ResourceBorrow { +impl Decode for ResourceBorrow { type Decoder = ResourceBorrowDecoder; type ListDecoder = CoreVecDecoder; } @@ -1163,7 +1159,7 @@ impl Deferred for CoreVecDecoder> { } } -impl Decode for ResourceOwn { +impl Decode for ResourceOwn { type Decoder = ResourceOwnDecoder; type ListDecoder = CoreVecDecoder; } @@ -1304,8 +1300,8 @@ macro_rules! impl_tuple_codec { R: crate::Index + Send + Sync + 'static, E: From, $( - $vt: Decode + Send + Sync + 'static, - $vt::Decoder: tokio_util::codec::Decoder + Send + Sync + 'static, + $vt: Decode + Send + 'static, + $vt::Decoder: tokio_util::codec::Decoder + Send + 'static, )+ { type Decoder = TupleDecoder::<($($vt::Decoder),+,), ($(Option<$vt>),+,)>; @@ -1317,8 +1313,8 @@ macro_rules! impl_tuple_codec { R: crate::Index + Send + Sync + 'static, E: From, $( - $vt: Decode + Send + Sync + 'static, - $vt::Decoder: tokio_util::codec::Decoder + Send + Sync + 'static, + $vt: Decode + Send + 'static, + $vt::Decoder: tokio_util::codec::Decoder + Send + 'static, )+ { } @@ -1457,7 +1453,7 @@ impl tokio_util::codec::Encoder for FutureEncoder where T: Encode, W: AsyncWrite + crate::Index + Send + Sync + Unpin + 'static, - Fut: Future + Send + Sync + 'static, + Fut: Future + Send + 'static, std::io::Error: From<>::Error>, { type Error = std::io::Error; @@ -1489,7 +1485,7 @@ where } } -impl Encode for Pin + Send + Sync>> +impl Encode for Pin + Send>> where T: Encode + 'static, W: AsyncWrite + crate::Index + Send + Sync + Unpin + 'static, @@ -1531,12 +1527,11 @@ where impl tokio_util::codec::Decoder for FutureDecoder where - T: Decode + Send + Sync + 'static, - T::Decoder: Sync, + T: Decode + Send + 'static, R: AsyncRead + crate::Index + Send + Sync + Unpin + 'static, std::io::Error: From<::Error>, { - type Item = Pin + Send + Sync>>; + type Item = Pin + Send>>; type Error = ::Error; #[instrument(level = "trace", skip(self), fields(ty = "future"))] @@ -1588,10 +1583,9 @@ where } } -impl Decode for Pin + Send + Sync>> +impl Decode for Pin + Send>> where - T: Decode + Send + Sync + 'static, - T::Decoder: Sync, + T: Decode + Send + 'static, R: AsyncRead + crate::Index + Send + Sync + Unpin + 'static, std::io::Error: From<::Error>, { @@ -1617,9 +1611,9 @@ impl Deferred for StreamEncoder { impl tokio_util::codec::Encoder for StreamEncoder where - T: Encode + Send + Sync + 'static, + T: Encode + Send + 'static, W: AsyncWrite + crate::Index + Send + Sync + Unpin + 'static, - S: Stream> + Send + Sync + Unpin + 'static, + S: Stream> + Send + Unpin + 'static, std::io::Error: From<>::Error>, { type Error = std::io::Error; @@ -1689,9 +1683,9 @@ where } } -impl Encode for Pin> + Send + Sync>> +impl Encode for Pin> + Send>> where - T: Encode + Send + Sync + 'static, + T: Encode + Send + 'static, W: AsyncWrite + crate::Index + Send + Sync + Unpin + 'static, std::io::Error: From<>::Error>, { @@ -1717,7 +1711,7 @@ impl Deferred for StreamEncoderBytes { impl tokio_util::codec::Encoder for StreamEncoderBytes where W: AsyncWrite + crate::Index + Send + Sync + Unpin + 'static, - S: Stream + Send + Sync + Unpin + 'static, + S: Stream + Send + Unpin + 'static, { type Error = std::io::Error; @@ -1758,7 +1752,7 @@ where } } -impl Encode for Pin + Send + Sync>> +impl Encode for Pin + Send>> where W: AsyncWrite + crate::Index + Send + Sync + Unpin + 'static, { @@ -1784,7 +1778,7 @@ impl Deferred for StreamEncoderRead { impl tokio_util::codec::Encoder for StreamEncoderRead where W: AsyncWrite + crate::Index + Send + Sync + Unpin + 'static, - S: AsyncRead + Send + Sync + Unpin + 'static, + S: AsyncRead + Send + Unpin + 'static, { type Error = std::io::Error; @@ -1828,7 +1822,7 @@ where } } -impl Encode for Pin> +impl Encode for Pin> where W: AsyncWrite + crate::Index + Send + Sync + Unpin + 'static, { @@ -1837,7 +1831,7 @@ where impl Encode for std::io::Cursor where - T: AsRef<[u8]> + Send + Sync + Unpin + 'static, + T: AsRef<[u8]> + Send + Unpin + 'static, W: AsyncWrite + crate::Index + Send + Sync + Unpin + 'static, { type Encoder = StreamEncoderRead; @@ -1930,7 +1924,7 @@ async fn handle_deferred_stream( ) -> std::io::Result<()> where C: tokio_util::codec::Decoder + Deferred, - R: AsyncRead + crate::Index + Send + Sync + Unpin + 'static, + R: AsyncRead + crate::Index + Send + Unpin + 'static, std::io::Error: From, { let dec = ListDecoder::new(dec); @@ -1982,14 +1976,13 @@ where impl tokio_util::codec::Decoder for StreamDecoder where - T: Decode + Send + Sync + 'static, - T::Decoder: Sync, + T: Decode + Send + 'static, T::ListDecoder: Deferred, R: AsyncRead + crate::Index + Send + Sync + Unpin + 'static, - ::Error: Send + Sync, + ::Error: Send, std::io::Error: From<::Error>, { - type Item = Pin> + Send + Sync>>; + type Item = Pin> + Send>>; type Error = <>::ListDecoder as tokio_util::codec::Decoder>::Error; #[instrument(level = "trace", skip(self), fields(ty = "stream"))] @@ -2013,13 +2006,12 @@ where } } -impl Decode for Pin> + Send + Sync>> +impl Decode for Pin> + Send>> where - T: Decode + Send + Sync + 'static, - T::Decoder: Sync, + T: Decode + Send + 'static, T::ListDecoder: Deferred + Send, R: AsyncRead + crate::Index + Send + Sync + Unpin + 'static, - ::Error: Send + Sync, + ::Error: Send, std::io::Error: From<::Error>, { type Decoder = StreamDecoder; @@ -2050,7 +2042,7 @@ impl tokio_util::codec::Decoder for StreamDecoderBytes where R: AsyncRead + crate::Index + Send + Sync + Unpin + 'static, { - type Item = Pin + Send + Sync>>; + type Item = Pin + Send>>; type Error = std::io::Error; #[instrument(level = "trace", skip(self), fields(ty = "stream"))] @@ -2091,7 +2083,7 @@ where } } -impl Decode for Pin + Send + Sync>> +impl Decode for Pin + Send>> where R: AsyncRead + crate::Index + Send + Sync + Unpin + 'static, { @@ -2123,7 +2115,7 @@ impl tokio_util::codec::Decoder for StreamDecoderRead where R: AsyncRead + crate::Index + Send + Sync + Unpin + 'static, { - type Item = Pin>; + type Item = Pin>; type Error = std::io::Error; #[instrument(level = "trace", skip(self), fields(ty = "stream"))] @@ -2164,7 +2156,7 @@ where } } -impl Decode for Pin> +impl Decode for Pin> where R: AsyncRead + crate::Index + Send + Sync + Unpin + 'static, { diff --git a/crates/wit-bindgen-rust-macro/Cargo.toml b/crates/wit-bindgen-rust-macro/Cargo.toml index 892ef288..1fd7441b 100644 --- a/crates/wit-bindgen-rust-macro/Cargo.toml +++ b/crates/wit-bindgen-rust-macro/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wit-bindgen-wrpc-rust-macro" -version = "0.4.4" +version = "0.4.5" description = """ Procedural macro paired with the `wit-bindgen-wrpc` crate. """ diff --git a/crates/wit-bindgen-rust/Cargo.toml b/crates/wit-bindgen-rust/Cargo.toml index 06c69daa..a27ace3c 100644 --- a/crates/wit-bindgen-rust/Cargo.toml +++ b/crates/wit-bindgen-rust/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wit-bindgen-wrpc-rust" -version = "0.4.4" +version = "0.4.5" description = """ Rust bindings generator for wRPC, typically used through the `wit-bindgen-wrpc` crate's `generate!` macro. diff --git a/crates/wit-bindgen-rust/src/interface.rs b/crates/wit-bindgen-rust/src/interface.rs index c99da9b5..efc2a33d 100644 --- a/crates/wit-bindgen-rust/src/interface.rs +++ b/crates/wit-bindgen-rust/src/interface.rs @@ -935,7 +935,7 @@ pub async fn serve_interface( } else { self.push_str("()"); } - self.push_str("> + ::core::marker::Send + ::core::marker::Sync>>"); + self.push_str("> + ::core::marker::Send>>"); } fn print_stream(&mut self, Stream { element, .. }: &Stream, submodule: bool) { @@ -949,7 +949,7 @@ pub async fn serve_interface( } else { self.push_str("Vec<()>"); } - self.push_str("> + ::core::marker::Send + ::core::marker::Sync>>"); + self.push_str("> + ::core::marker::Send>>"); } fn print_own(&mut self, id: TypeId, submodule: bool) { diff --git a/crates/wit-bindgen/Cargo.toml b/crates/wit-bindgen/Cargo.toml index 9fbfb1d5..431bdf11 100644 --- a/crates/wit-bindgen/Cargo.toml +++ b/crates/wit-bindgen/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wit-bindgen-wrpc" -version = "0.4.4" +version = "0.4.5" description = """ Rust bindings generator for wRPC. """ diff --git a/tests/rust.rs b/tests/rust.rs index 7246adda..cb775fa9 100644 --- a/tests/rust.rs +++ b/tests/rust.rs @@ -234,8 +234,8 @@ where &self, _cx: C, ) -> anyhow::Result<( - Pin + Send + Sync>>, - Pin>> + Send + Sync>>, + Pin + Send>>, + Pin>> + Send>>, )> { Ok(( Box::pin(stream::iter([Bytes::from("test")])), @@ -249,15 +249,9 @@ where async fn with_future( &self, _cx: C, - s: Pin + Send + Sync>>, + s: Pin + Send>>, ) -> anyhow::Result< - Pin< - Box< - dyn Future + Send + Sync>>> - + Send - + Sync, - >, - >, + Pin + Send>>> + Send>>, > { Ok(Box::pin(async { s })) } @@ -687,10 +681,10 @@ where .expect("failed to accept invocation") .expect("unexpected end of stream"); let (a, b, mut c, d): ( - Pin> + Send + Sync>>, - Pin> + Send + Sync>>, - Pin>, - Pin> + Send + Sync>>, + Pin> + Send>>, + Pin> + Send>>, + Pin>, + Pin> + Send>>, ) = params; let io = rx.map(Instrument::in_current_span).map(spawn); join!( @@ -721,25 +715,25 @@ where } } ); - let a: Pin> + Send + Sync>> = + let a: Pin> + Send>> = Box::pin(stream::iter([vec![0xc0, 0xff], vec![0xee]])); - let b: Pin> + Send + Sync>> = + let b: Pin> + Send>> = Box::pin(stream::iter([vec!["foo"], vec!["bar"]])); - let c: Pin> = Box::pin(b"test".as_slice()); - let d: Pin> + Send + Sync>> = + let c: Pin> = Box::pin(b"test".as_slice()); + let d: Pin> + Send>> = Box::pin(async { vec![1, 2, 3] }); info!("transmitting `test.async` returns"); tx((a, b, c, d)).await.expect("failed to send response"); } .instrument(info_span!("server")), async { - let a: Pin> + Send + Sync>> = + let a: Pin> + Send>> = Box::pin(stream::iter([vec![0xc0, 0xff, 0xee]])); - let b: Pin> + Send + Sync>> = + let b: Pin> + Send>> = Box::pin(stream::iter([vec!["foo", "bar"]])); - let c: Pin> = Box::pin(b"test".as_slice()); - let d: Pin> + Send + Sync>> = + let c: Pin> = Box::pin(b"test".as_slice()); + let d: Pin> + Send>> = Box::pin(async { vec![1, 2, 3] }); info!("invoking `test.async`"); let (returns, io) = clt @@ -753,10 +747,10 @@ where .await .expect("failed to invoke `test.async`"); let (a, b, mut c, d): ( - Pin> + Send + Sync>>, - Pin> + Send + Sync>>, - Pin>, - Pin> + Send + Sync>>, + Pin> + Send>>, + Pin> + Send>>, + Pin>, + Pin> + Send>>, ) = returns; info!("receiving `test.async` async values"); join!(