Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions crates/transport/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,6 @@ use bytes::BytesMut;
use tokio::io::{AsyncRead, ReadBuf};
use tracing::trace;

/// Internal workaround trait
///
/// This is an internal trait used as a workaround for
/// https://github.com/rust-lang/rust/issues/63033
#[doc(hidden)]
pub trait Captures<'a> {}

impl<T: ?Sized> Captures<'_> for T {}

/// Buffered incoming stream used for decoding values
///
/// This wraps the multiplexed framed [`frame::Incoming`] stream with a read buffer used to
Expand Down
6 changes: 2 additions & 4 deletions crates/transport/src/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ mod tests {
use bytes::Bytes;
use futures::{StreamExt as _, TryStreamExt as _, stream};

use crate::Captures;

use super::*;

async fn call_serve<T: Serve>(s: &T) -> anyhow::Result<Vec<(T::Context, Outgoing, Incoming)>> {
Expand Down Expand Up @@ -198,7 +196,7 @@ mod tests {
s: &T,
) -> impl Future<
Output = anyhow::Result<Pin<Box<dyn Stream<Item = anyhow::Result<T::Context>> + 'static>>>,
> + Captures<'_> {
> {
let fut = s.serve(
"foo",
"bar",
Expand All @@ -215,7 +213,7 @@ mod tests {
s: &T,
) -> impl Future<
Output = anyhow::Result<Pin<Box<dyn Stream<Item = anyhow::Result<T::Context>> + 'static>>>,
> + crate::Captures<'_> {
> {
let fut = s.serve_values::<(Bytes,), (Bytes,)>(
"foo",
"bar",
Expand Down
12 changes: 5 additions & 7 deletions crates/wit-bindgen-rust/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ impl InterfaceGenerator<'_> {
self.src,
r#"
#[allow(clippy::manual_async_fn)]
pub fn serve_interface<'a, T: {wrpc_transport}::Serve>(
pub fn serve_interface<'a, T: {wrpc_transport}::Serve, H: Handler<T::Context> + {resource_traits} ::core::marker::Send + ::core::marker::Sync + ::core::clone::Clone + 'static>(
wrpc: &'a T,
handler: impl Handler<T::Context> + {resource_traits} ::core::marker::Send + ::core::marker::Sync + ::core::clone::Clone + 'static,
handler: H,
) -> impl ::core::future::Future<
Output = {anyhow}::Result<
[
Expand All @@ -171,7 +171,7 @@ pub fn serve_interface<'a, T: {wrpc_transport}::Serve>(
{n}
]
>
> + ::core::marker::Send + {wrpc_transport}::Captures<'a> {{
> + ::core::marker::Send + use<'a, T, H> {{
async move {{
let ("#,
resource_traits = trait_names.join(""),
Expand Down Expand Up @@ -602,8 +602,7 @@ pub fn serve_interface<'a, T: {wrpc_transport}::Serve>(
if async_params || !paths.is_empty() {
uwrite!(
self.src,
", ::core::option::Option<impl ::core::future::Future<Output = {anyhow}::Result<()>> + ::core::marker::Send + 'static + {wrpc_transport}::Captures<'a>>)",
wrpc_transport = self.r#gen.wrpc_transport_path(),
", ::core::option::Option<impl ::core::future::Future<Output = {anyhow}::Result<()>> + ::core::marker::Send + 'static + use<'a, C__>>)",
);
}
uwrite!(self.src, ">> + Send + 'a");
Expand All @@ -620,8 +619,7 @@ pub fn serve_interface<'a, T: {wrpc_transport}::Serve>(
if async_params || !paths.is_empty() {
uwrite!(
self.src,
"::core::option::Option<impl ::core::future::Future<Output = {anyhow}::Result<()>> + ::core::marker::Send + 'static + {wrpc_transport}::Captures<'a>>",
wrpc_transport = self.r#gen.wrpc_transport_path(),
"::core::option::Option<impl ::core::future::Future<Output = {anyhow}::Result<()>> + ::core::marker::Send + 'static + use<'a, C__>>",
);
}
uwrite!(self.src, ")>> + Send + 'a");
Expand Down
6 changes: 3 additions & 3 deletions crates/wit-bindgen-rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,9 @@ with: {{\n\t{with_name:?}: generate\n}}
self.src,
r#"
#[allow(clippy::manual_async_fn)]
pub fn serve<'a, T: {wrpc_transport}::Serve>(
pub fn serve<'a, T: {wrpc_transport}::Serve, H: {bound} + ::core::marker::Send + ::core::marker::Sync + ::core::clone::Clone + 'static>(
wrpc: &'a T,
handler: impl {bound} + ::core::marker::Send + ::core::marker::Sync + ::core::clone::Clone + 'static,
handler: H,
) -> impl ::core::future::Future<
Output = {anyhow}::Result<
::std::vec::Vec<
Expand All @@ -455,7 +455,7 @@ pub fn serve<'a, T: {wrpc_transport}::Serve>(
)
>
>
> + ::core::marker::Send + {wrpc_transport}::Captures<'a> {{
> + ::core::marker::Send + use<'a, T, H> {{
async move {{
let interfaces = {tokio}::try_join!("#
);
Expand Down
Loading