diff --git a/.changes/unreleased/Fixed-20261004-215800.yaml b/.changes/unreleased/Fixed-20261004-215800.yaml new file mode 100644 index 00000000..e3eedebb --- /dev/null +++ b/.changes/unreleased/Fixed-20261004-215800.yaml @@ -0,0 +1,14 @@ +kind: Fixed +body: |- + **Proto types and services named after Rust prelude items compile.** + Generated service code wrote `Result`, `Option`, `Box`, `Send`, `Sync`, + `Clone` and `Into` without a path. A message, enum or service with one of + those names in the same package or a parent package (`message Result`, as + in Arrow Flight) took its place, and the build failed inside + `*.__connect.rs` with errors such as E0107 (`struct takes 0 generic + arguments`) or E0404 (`expected trait, found struct`). Generated code now + writes the full path, such as `::std::result::Result`. It reaches a message + or service named `S` or `T`, the generic parameters of the generated `impl` + blocks, as `self::S`. Regenerate checked-in code to pick this up: every + `*.__connect.rs` file changes, and the generated API stays the same. +time: 2026-10-04T21:58:00.000000000+00:00 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 38d7d4fa..2529f736 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -108,6 +108,19 @@ Key rules: (`::connectrpc::...`, `::buffa::...`) — no `use` statements at module scope. This lets multiple generated files be `include!`d into the same Rust module without E0252 collisions. +- Fully-qualified paths include **the prelude**: write + `::std::result::Result`, `::std::marker::Send`, + `::std::option::Option::Some`. In `connectrpc-build` output the stubs + share a module with the package's messages and enums, and in every layout + each `pub mod` has `use super::*;`. So `message Result` or `service Send`, + in the package or a parent package, shadows the prelude there. The + `stubs_resolve_only_their_own_names` test fails when a template writes a + type, trait or module that the stubs do not declare without a `::` root. + It skips attributes (`#[derive(Clone)]`) and primitives (`str`). +- Every **generic type parameter** that a template declares goes in + `GENERIC_PARAMS`, so that a message, service or sub-package of the same + name is reached through `self::` (`message T` is written `self::T`). The + same test fails on a parameter that is not listed. ## Conformance Tests diff --git a/benches/rpc/src/generated/connect/bench.__connect.rs b/benches/rpc/src/generated/connect/bench.__connect.rs index d9c7b562..7fce1070 100644 --- a/benches/rpc/src/generated/connect/bench.__connect.rs +++ b/benches/rpc/src/generated/connect/bench.__connect.rs @@ -250,7 +250,7 @@ pub const BENCH_SERVICE_LOG_UNARY_OWNED_SPEC: ::connectrpc::Spec = ::connectrpc: /// [`PreEncoded`](::connectrpc::PreEncoded) — see its `# Streaming /// example` doc. #[allow(clippy::type_complexity)] -pub trait BenchService: Send + Sync + 'static { +pub trait BenchService: ::std::marker::Send + ::std::marker::Sync + 'static { /// Handle the Unary RPC. /// /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). @@ -268,9 +268,9 @@ pub trait BenchService: Send + Sync + 'static { Output = ::connectrpc::ServiceResult< impl ::connectrpc::Encodable< crate::proto::bench::v1::BenchResponse, - > + Send + use<'a, Self>, + > + ::std::marker::Send + use<'a, Self>, >, - > + Send; + > + ::std::marker::Send; /// Handle the ServerStream RPC. /// /// `request` is borrowed from the request body and is valid for the @@ -287,10 +287,10 @@ pub trait BenchService: Send + Sync + 'static { ::connectrpc::ServiceStream< impl ::connectrpc::Encodable< crate::proto::bench::v1::BenchResponse, - > + Send + use, + > + ::std::marker::Send + use, >, >, - > + Send; + > + ::std::marker::Send; /// Handle the ClientStream RPC. /// /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). @@ -307,9 +307,9 @@ pub trait BenchService: Send + Sync + 'static { Output = ::connectrpc::ServiceResult< impl ::connectrpc::Encodable< crate::proto::bench::v1::BenchResponse, - > + Send + use<'a, Self>, + > + ::std::marker::Send + use<'a, Self>, >, - > + Send; + > + ::std::marker::Send; /// Handle the BidiStream RPC. /// /// Each `requests` item is a [`StreamMessage`](::connectrpc::StreamMessage): @@ -325,10 +325,10 @@ pub trait BenchService: Send + Sync + 'static { ::connectrpc::ServiceStream< impl ::connectrpc::Encodable< crate::proto::bench::v1::BenchResponse, - > + Send + use, + > + ::std::marker::Send + use, >, >, - > + Send; + > + ::std::marker::Send; /// Handle the LogUnary RPC. /// /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). @@ -346,9 +346,9 @@ pub trait BenchService: Send + Sync + 'static { Output = ::connectrpc::ServiceResult< impl ::connectrpc::Encodable< crate::proto::bench::v1::LogResponse, - > + Send + use<'a, Self>, + > + ::std::marker::Send + use<'a, Self>, >, - > + Send; + > + ::std::marker::Send; /// Handle the LogUnaryOwned RPC. /// /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). @@ -366,9 +366,9 @@ pub trait BenchService: Send + Sync + 'static { Output = ::connectrpc::ServiceResult< impl ::connectrpc::Encodable< crate::proto::bench::v1::LogResponse, - > + Send + use<'a, Self>, + > + ::std::marker::Send + use<'a, Self>, >, - > + Send; + > + ::std::marker::Send; } /// Extension trait for registering a service implementation with a Router. /// @@ -589,7 +589,7 @@ impl BenchServiceServer { Self { inner } } } -impl Clone for BenchServiceServer { +impl ::std::clone::Clone for BenchServiceServer { fn clone(&self) -> Self { Self { inner: ::std::sync::Arc::clone(&self.inner), @@ -601,46 +601,46 @@ impl ::connectrpc::Dispatcher for BenchServiceServer { fn lookup( &self, path: &str, - ) -> Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { + ) -> ::std::option::Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { let method = path.strip_prefix("bench.v1.BenchService/")?; match method { "Unary" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) .with_spec(BENCH_SERVICE_UNARY_SPEC), ) } "ServerStream" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::server_streaming() .with_spec(BENCH_SERVICE_SERVER_STREAM_SPEC), ) } "ClientStream" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::client_streaming() .with_spec(BENCH_SERVICE_CLIENT_STREAM_SPEC), ) } "BidiStream" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::bidi_streaming() .with_spec(BENCH_SERVICE_BIDI_STREAM_SPEC), ) } "LogUnary" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) .with_spec(BENCH_SERVICE_LOG_UNARY_SPEC), ) } "LogUnaryOwned" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) .with_spec(BENCH_SERVICE_LOG_UNARY_OWNED_SPEC), ) } - _ => None, + _ => ::std::option::Option::None, } } fn call_unary( @@ -650,14 +650,15 @@ impl ::connectrpc::Dispatcher for BenchServiceServer { request: ::connectrpc::Payload, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path.strip_prefix("bench.v1.BenchService/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("bench.v1.BenchService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; let _ = (&ctx, &request, &format); match method { "Unary" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let body = ::connectrpc::dispatcher::codegen::request_proto_bytes::< crate::proto::bench::v1::BenchRequest, >(request.encoded()?, format)?; @@ -677,7 +678,7 @@ impl ::connectrpc::Dispatcher for BenchServiceServer { } "LogUnary" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let body = ::connectrpc::dispatcher::codegen::request_proto_bytes::< crate::proto::bench::v1::LogRequest, >(request.encoded()?, format)?; @@ -697,7 +698,7 @@ impl ::connectrpc::Dispatcher for BenchServiceServer { } "LogUnaryOwned" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let body = ::connectrpc::dispatcher::codegen::request_proto_bytes::< crate::proto::bench::v1::LogRequest, >(request.encoded()?, format)?; @@ -725,14 +726,15 @@ impl ::connectrpc::Dispatcher for BenchServiceServer { request: ::buffa::bytes::Bytes, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path.strip_prefix("bench.v1.BenchService/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("bench.v1.BenchService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; let _ = (&ctx, &request, &format); match method { "ServerStream" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let body = ::connectrpc::dispatcher::codegen::request_proto_bytes::< crate::proto::bench::v1::BenchRequest, >(request, format)?; @@ -746,7 +748,7 @@ impl ::connectrpc::Dispatcher for BenchServiceServer { crate::proto::bench::v1::BenchRequest, >::from_parts(&req, &body); let resp = svc.server_stream(ctx, req).await?; - Ok( + ::std::result::Result::Ok( resp .map_body(|s| ::connectrpc::dispatcher::codegen::encode_response_stream::< crate::proto::bench::v1::BenchResponse, @@ -766,14 +768,15 @@ impl ::connectrpc::Dispatcher for BenchServiceServer { requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path.strip_prefix("bench.v1.BenchService/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("bench.v1.BenchService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; let _ = (&ctx, &requests, &format); match method { "ClientStream" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let req_stream = ::connectrpc::dispatcher::codegen::decode_message_request_stream::< crate::proto::bench::v1::BenchRequest, >(requests, format, ctx.decode_options().clone()); @@ -792,19 +795,20 @@ impl ::connectrpc::Dispatcher for BenchServiceServer { requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path.strip_prefix("bench.v1.BenchService/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("bench.v1.BenchService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; let _ = (&ctx, &requests, &format); match method { "BidiStream" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let req_stream = ::connectrpc::dispatcher::codegen::decode_message_request_stream::< crate::proto::bench::v1::BenchRequest, >(requests, format, ctx.decode_options().clone()); let resp = svc.bidi_stream(ctx, req_stream).await?; - Ok( + ::std::result::Result::Ok( resp .map_body(|s| ::connectrpc::dispatcher::codegen::encode_response_stream::< crate::proto::bench::v1::BenchResponse, @@ -887,8 +891,10 @@ pub struct BenchServiceClient { impl BenchServiceClient where T: ::connectrpc::client::ClientTransport, - ::Error: Into< - Box, + ::Error: ::std::convert::Into< + ::std::boxed::Box< + dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync, + >, >, { /// Create a new client with the given transport and configuration. @@ -907,7 +913,7 @@ where pub async fn unary( &self, request: crate::proto::bench::v1::BenchRequest, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::bench::v1::__buffa::view::BenchResponseView<'static>, @@ -923,7 +929,7 @@ where &self, request: crate::proto::bench::v1::BenchRequest, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::bench::v1::__buffa::view::BenchResponseView<'static>, @@ -944,7 +950,7 @@ where pub async fn server_stream( &self, request: crate::proto::bench::v1::BenchRequest, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::ServerStream< T::ResponseBody, crate::proto::bench::v1::__buffa::view::BenchResponseView<'static>, @@ -962,7 +968,7 @@ where &self, request: crate::proto::bench::v1::BenchRequest, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::ServerStream< T::ResponseBody, crate::proto::bench::v1::__buffa::view::BenchResponseView<'static>, @@ -998,7 +1004,7 @@ where requests: impl ::connectrpc::client::ClientRequestStream< crate::proto::bench::v1::BenchRequest, >, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::bench::v1::__buffa::view::BenchResponseView<'static>, @@ -1032,7 +1038,7 @@ where crate::proto::bench::v1::BenchRequest, >, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::bench::v1::__buffa::view::BenchResponseView<'static>, @@ -1053,7 +1059,7 @@ where /// Call the BidiStream RPC. Sends a request to /bench.v1.BenchService/BidiStream. pub async fn bidi_stream( &self, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::BidiStream< T::ResponseBody, crate::proto::bench::v1::BenchRequest, @@ -1067,7 +1073,7 @@ where pub async fn bidi_stream_with_options( &self, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::BidiStream< T::ResponseBody, crate::proto::bench::v1::BenchRequest, @@ -1088,7 +1094,7 @@ where pub async fn log_unary( &self, request: crate::proto::bench::v1::LogRequest, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::bench::v1::__buffa::view::LogResponseView<'static>, @@ -1107,7 +1113,7 @@ where &self, request: crate::proto::bench::v1::LogRequest, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::bench::v1::__buffa::view::LogResponseView<'static>, @@ -1129,7 +1135,7 @@ where pub async fn log_unary_owned( &self, request: crate::proto::bench::v1::LogRequest, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::bench::v1::__buffa::view::LogResponseView<'static>, @@ -1148,7 +1154,7 @@ where &self, request: crate::proto::bench::v1::LogRequest, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::bench::v1::__buffa::view::LogResponseView<'static>, @@ -1227,7 +1233,7 @@ pub const ECHO_SERVICE_ECHO_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::serve /// [`PreEncoded`](::connectrpc::PreEncoded) — see its `# Streaming /// example` doc. #[allow(clippy::type_complexity)] -pub trait EchoService: Send + Sync + 'static { +pub trait EchoService: ::std::marker::Send + ::std::marker::Sync + 'static { /// Handle the Echo RPC. /// /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). @@ -1245,9 +1251,9 @@ pub trait EchoService: Send + Sync + 'static { Output = ::connectrpc::ServiceResult< impl ::connectrpc::Encodable< crate::proto::bench::v1::EchoResponse, - > + Send + use<'a, Self>, + > + ::std::marker::Send + use<'a, Self>, >, - > + Send; + > + ::std::marker::Send; } /// Extension trait for registering a service implementation with a Router. /// @@ -1346,7 +1352,7 @@ impl EchoServiceServer { Self { inner } } } -impl Clone for EchoServiceServer { +impl ::std::clone::Clone for EchoServiceServer { fn clone(&self) -> Self { Self { inner: ::std::sync::Arc::clone(&self.inner), @@ -1358,16 +1364,16 @@ impl ::connectrpc::Dispatcher for EchoServiceServer { fn lookup( &self, path: &str, - ) -> Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { + ) -> ::std::option::Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { let method = path.strip_prefix("bench.v1.EchoService/")?; match method { "Echo" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) .with_spec(ECHO_SERVICE_ECHO_SPEC), ) } - _ => None, + _ => ::std::option::Option::None, } } fn call_unary( @@ -1377,14 +1383,15 @@ impl ::connectrpc::Dispatcher for EchoServiceServer { request: ::connectrpc::Payload, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path.strip_prefix("bench.v1.EchoService/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("bench.v1.EchoService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; let _ = (&ctx, &request, &format); match method { "Echo" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let body = ::connectrpc::dispatcher::codegen::request_proto_bytes::< crate::proto::bench::v1::EchoRequest, >(request.encoded()?, format)?; @@ -1412,7 +1419,8 @@ impl ::connectrpc::Dispatcher for EchoServiceServer { request: ::buffa::bytes::Bytes, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path.strip_prefix("bench.v1.EchoService/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("bench.v1.EchoService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; let _ = (&ctx, &request, &format); @@ -1427,7 +1435,8 @@ impl ::connectrpc::Dispatcher for EchoServiceServer { requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path.strip_prefix("bench.v1.EchoService/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("bench.v1.EchoService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; let _ = (&ctx, &requests, &format); @@ -1442,7 +1451,8 @@ impl ::connectrpc::Dispatcher for EchoServiceServer { requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path.strip_prefix("bench.v1.EchoService/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("bench.v1.EchoService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; let _ = (&ctx, &requests, &format); @@ -1520,8 +1530,10 @@ pub struct EchoServiceClient { impl EchoServiceClient where T: ::connectrpc::client::ClientTransport, - ::Error: Into< - Box, + ::Error: ::std::convert::Into< + ::std::boxed::Box< + dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync, + >, >, { /// Create a new client with the given transport and configuration. @@ -1540,7 +1552,7 @@ where pub async fn echo( &self, request: crate::proto::bench::v1::EchoRequest, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::bench::v1::__buffa::view::EchoResponseView<'static>, @@ -1556,7 +1568,7 @@ where &self, request: crate::proto::bench::v1::EchoRequest, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::bench::v1::__buffa::view::EchoResponseView<'static>, @@ -1632,7 +1644,7 @@ pub const LOG_INGEST_SERVICE_INGEST_SPEC: ::connectrpc::Spec = ::connectrpc::Spe /// [`PreEncoded`](::connectrpc::PreEncoded) — see its `# Streaming /// example` doc. #[allow(clippy::type_complexity)] -pub trait LogIngestService: Send + Sync + 'static { +pub trait LogIngestService: ::std::marker::Send + ::std::marker::Sync + 'static { /// Handle the Ingest RPC. /// /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). @@ -1650,9 +1662,9 @@ pub trait LogIngestService: Send + Sync + 'static { Output = ::connectrpc::ServiceResult< impl ::connectrpc::Encodable< crate::proto::bench::v1::LogIngestResponse, - > + Send + use<'a, Self>, + > + ::std::marker::Send + use<'a, Self>, >, - > + Send; + > + ::std::marker::Send; } /// Extension trait for registering a service implementation with a Router. /// @@ -1753,7 +1765,7 @@ impl LogIngestServiceServer { Self { inner } } } -impl Clone for LogIngestServiceServer { +impl ::std::clone::Clone for LogIngestServiceServer { fn clone(&self) -> Self { Self { inner: ::std::sync::Arc::clone(&self.inner), @@ -1765,16 +1777,16 @@ impl ::connectrpc::Dispatcher for LogIngestServiceServer fn lookup( &self, path: &str, - ) -> Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { + ) -> ::std::option::Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { let method = path.strip_prefix("bench.v1.LogIngestService/")?; match method { "Ingest" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) .with_spec(LOG_INGEST_SERVICE_INGEST_SPEC), ) } - _ => None, + _ => ::std::option::Option::None, } } fn call_unary( @@ -1784,14 +1796,15 @@ impl ::connectrpc::Dispatcher for LogIngestServiceServer request: ::connectrpc::Payload, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path.strip_prefix("bench.v1.LogIngestService/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("bench.v1.LogIngestService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; let _ = (&ctx, &request, &format); match method { "Ingest" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let body = ::connectrpc::dispatcher::codegen::request_proto_bytes::< crate::proto::bench::v1::LogRequest, >(request.encoded()?, format)?; @@ -1819,7 +1832,8 @@ impl ::connectrpc::Dispatcher for LogIngestServiceServer request: ::buffa::bytes::Bytes, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path.strip_prefix("bench.v1.LogIngestService/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("bench.v1.LogIngestService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; let _ = (&ctx, &request, &format); @@ -1834,7 +1848,8 @@ impl ::connectrpc::Dispatcher for LogIngestServiceServer requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path.strip_prefix("bench.v1.LogIngestService/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("bench.v1.LogIngestService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; let _ = (&ctx, &requests, &format); @@ -1849,7 +1864,8 @@ impl ::connectrpc::Dispatcher for LogIngestServiceServer requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path.strip_prefix("bench.v1.LogIngestService/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("bench.v1.LogIngestService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; let _ = (&ctx, &requests, &format); @@ -1927,8 +1943,10 @@ pub struct LogIngestServiceClient { impl LogIngestServiceClient where T: ::connectrpc::client::ClientTransport, - ::Error: Into< - Box, + ::Error: ::std::convert::Into< + ::std::boxed::Box< + dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync, + >, >, { /// Create a new client with the given transport and configuration. @@ -1947,7 +1965,7 @@ where pub async fn ingest( &self, request: crate::proto::bench::v1::LogRequest, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::bench::v1::__buffa::view::LogIngestResponseView<'static>, @@ -1963,7 +1981,7 @@ where &self, request: crate::proto::bench::v1::LogRequest, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::bench::v1::__buffa::view::LogIngestResponseView<'static>, diff --git a/benches/rpc/src/generated/connect/bench_noutf8.__connect.rs b/benches/rpc/src/generated/connect/bench_noutf8.__connect.rs index dcd57bcb..28a34a72 100644 --- a/benches/rpc/src/generated/connect/bench_noutf8.__connect.rs +++ b/benches/rpc/src/generated/connect/bench_noutf8.__connect.rs @@ -98,7 +98,7 @@ pub const LOG_INGEST_SERVICE_INGEST_SPEC: ::connectrpc::Spec = ::connectrpc::Spe /// [`PreEncoded`](::connectrpc::PreEncoded) — see its `# Streaming /// example` doc. #[allow(clippy::type_complexity)] -pub trait LogIngestService: Send + Sync + 'static { +pub trait LogIngestService: ::std::marker::Send + ::std::marker::Sync + 'static { /// Handle the Ingest RPC. /// /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). @@ -119,9 +119,9 @@ pub trait LogIngestService: Send + Sync + 'static { Output = ::connectrpc::ServiceResult< impl ::connectrpc::Encodable< crate::proto::bench::noutf8::v1::LogIngestResponse, - > + Send + use<'a, Self>, + > + ::std::marker::Send + use<'a, Self>, >, - > + Send; + > + ::std::marker::Send; } /// Extension trait for registering a service implementation with a Router. /// @@ -222,7 +222,7 @@ impl LogIngestServiceServer { Self { inner } } } -impl Clone for LogIngestServiceServer { +impl ::std::clone::Clone for LogIngestServiceServer { fn clone(&self) -> Self { Self { inner: ::std::sync::Arc::clone(&self.inner), @@ -234,16 +234,16 @@ impl ::connectrpc::Dispatcher for LogIngestServiceServer fn lookup( &self, path: &str, - ) -> Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { + ) -> ::std::option::Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { let method = path.strip_prefix("bench.noutf8.v1.LogIngestService/")?; match method { "Ingest" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) .with_spec(LOG_INGEST_SERVICE_INGEST_SPEC), ) } - _ => None, + _ => ::std::option::Option::None, } } fn call_unary( @@ -253,14 +253,15 @@ impl ::connectrpc::Dispatcher for LogIngestServiceServer request: ::connectrpc::Payload, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path.strip_prefix("bench.noutf8.v1.LogIngestService/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("bench.noutf8.v1.LogIngestService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; let _ = (&ctx, &request, &format); match method { "Ingest" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let body = ::connectrpc::dispatcher::codegen::request_proto_bytes::< crate::proto::bench::noutf8::v1::LogRequest, >(request.encoded()?, format)?; @@ -290,7 +291,8 @@ impl ::connectrpc::Dispatcher for LogIngestServiceServer request: ::buffa::bytes::Bytes, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path.strip_prefix("bench.noutf8.v1.LogIngestService/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("bench.noutf8.v1.LogIngestService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; let _ = (&ctx, &request, &format); @@ -305,7 +307,8 @@ impl ::connectrpc::Dispatcher for LogIngestServiceServer requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path.strip_prefix("bench.noutf8.v1.LogIngestService/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("bench.noutf8.v1.LogIngestService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; let _ = (&ctx, &requests, &format); @@ -320,7 +323,8 @@ impl ::connectrpc::Dispatcher for LogIngestServiceServer requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path.strip_prefix("bench.noutf8.v1.LogIngestService/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("bench.noutf8.v1.LogIngestService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; let _ = (&ctx, &requests, &format); @@ -398,8 +402,10 @@ pub struct LogIngestServiceClient { impl LogIngestServiceClient where T: ::connectrpc::client::ClientTransport, - ::Error: Into< - Box, + ::Error: ::std::convert::Into< + ::std::boxed::Box< + dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync, + >, >, { /// Create a new client with the given transport and configuration. @@ -418,7 +424,7 @@ where pub async fn ingest( &self, request: crate::proto::bench::noutf8::v1::LogRequest, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::bench::noutf8::v1::__buffa::view::LogIngestResponseView< @@ -436,7 +442,7 @@ where &self, request: crate::proto::bench::noutf8::v1::LogRequest, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::bench::noutf8::v1::__buffa::view::LogIngestResponseView< diff --git a/benches/rpc/src/generated/connect/echo_bloat.__connect.rs b/benches/rpc/src/generated/connect/echo_bloat.__connect.rs index 15784b02..c28348e7 100644 --- a/benches/rpc/src/generated/connect/echo_bloat.__connect.rs +++ b/benches/rpc/src/generated/connect/echo_bloat.__connect.rs @@ -100,7 +100,7 @@ pub const BLOAT_ECHO_SERVICE_ECHO_SPEC: ::connectrpc::Spec = ::connectrpc::Spec: /// [`PreEncoded`](::connectrpc::PreEncoded) — see its `# Streaming /// example` doc. #[allow(clippy::type_complexity)] -pub trait BloatEchoService: Send + Sync + 'static { +pub trait BloatEchoService: ::std::marker::Send + ::std::marker::Sync + 'static { /// Handle the Echo RPC. /// /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). @@ -118,9 +118,9 @@ pub trait BloatEchoService: Send + Sync + 'static { Output = ::connectrpc::ServiceResult< impl ::connectrpc::Encodable< crate::proto::bench::v1::BloatEcho, - > + Send + use<'a, Self>, + > + ::std::marker::Send + use<'a, Self>, >, - > + Send; + > + ::std::marker::Send; } /// Extension trait for registering a service implementation with a Router. /// @@ -219,7 +219,7 @@ impl BloatEchoServiceServer { Self { inner } } } -impl Clone for BloatEchoServiceServer { +impl ::std::clone::Clone for BloatEchoServiceServer { fn clone(&self) -> Self { Self { inner: ::std::sync::Arc::clone(&self.inner), @@ -231,16 +231,16 @@ impl ::connectrpc::Dispatcher for BloatEchoServiceServer fn lookup( &self, path: &str, - ) -> Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { + ) -> ::std::option::Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { let method = path.strip_prefix("bench.v1.BloatEchoService/")?; match method { "Echo" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) .with_spec(BLOAT_ECHO_SERVICE_ECHO_SPEC), ) } - _ => None, + _ => ::std::option::Option::None, } } fn call_unary( @@ -250,14 +250,15 @@ impl ::connectrpc::Dispatcher for BloatEchoServiceServer request: ::connectrpc::Payload, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path.strip_prefix("bench.v1.BloatEchoService/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("bench.v1.BloatEchoService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; let _ = (&ctx, &request, &format); match method { "Echo" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let body = ::connectrpc::dispatcher::codegen::request_proto_bytes::< crate::proto::bench::v1::BloatEcho, >(request.encoded()?, format)?; @@ -283,7 +284,8 @@ impl ::connectrpc::Dispatcher for BloatEchoServiceServer request: ::buffa::bytes::Bytes, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path.strip_prefix("bench.v1.BloatEchoService/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("bench.v1.BloatEchoService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; let _ = (&ctx, &request, &format); @@ -298,7 +300,8 @@ impl ::connectrpc::Dispatcher for BloatEchoServiceServer requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path.strip_prefix("bench.v1.BloatEchoService/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("bench.v1.BloatEchoService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; let _ = (&ctx, &requests, &format); @@ -313,7 +316,8 @@ impl ::connectrpc::Dispatcher for BloatEchoServiceServer requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path.strip_prefix("bench.v1.BloatEchoService/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("bench.v1.BloatEchoService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; let _ = (&ctx, &requests, &format); @@ -391,8 +395,10 @@ pub struct BloatEchoServiceClient { impl BloatEchoServiceClient where T: ::connectrpc::client::ClientTransport, - ::Error: Into< - Box, + ::Error: ::std::convert::Into< + ::std::boxed::Box< + dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync, + >, >, { /// Create a new client with the given transport and configuration. @@ -411,7 +417,7 @@ where pub async fn echo( &self, request: crate::proto::bench::v1::BloatEcho, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::bench::v1::__buffa::view::BloatEchoView<'static>, @@ -427,7 +433,7 @@ where &self, request: crate::proto::bench::v1::BloatEcho, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::bench::v1::__buffa::view::BloatEchoView<'static>, diff --git a/benches/rpc/src/generated/connect/filter.__connect.rs b/benches/rpc/src/generated/connect/filter.__connect.rs index 67b9e6b6..63be0c5a 100644 --- a/benches/rpc/src/generated/connect/filter.__connect.rs +++ b/benches/rpc/src/generated/connect/filter.__connect.rs @@ -96,7 +96,7 @@ pub const FILTER_SERVICE_REDACT_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::s /// [`PreEncoded`](::connectrpc::PreEncoded) — see its `# Streaming /// example` doc. #[allow(clippy::type_complexity)] -pub trait FilterService: Send + Sync + 'static { +pub trait FilterService: ::std::marker::Send + ::std::marker::Sync + 'static { /// Handle the Redact RPC. /// /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). @@ -117,9 +117,9 @@ pub trait FilterService: Send + Sync + 'static { Output = ::connectrpc::ServiceResult< impl ::connectrpc::Encodable< crate::proto::anthropic::connectrpc::filter::v1::Record, - > + Send + use<'a, Self>, + > + ::std::marker::Send + use<'a, Self>, >, - > + Send; + > + ::std::marker::Send; } /// Extension trait for registering a service implementation with a Router. /// @@ -220,7 +220,7 @@ impl FilterServiceServer { Self { inner } } } -impl Clone for FilterServiceServer { +impl ::std::clone::Clone for FilterServiceServer { fn clone(&self) -> Self { Self { inner: ::std::sync::Arc::clone(&self.inner), @@ -232,16 +232,16 @@ impl ::connectrpc::Dispatcher for FilterServiceServer { fn lookup( &self, path: &str, - ) -> Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { + ) -> ::std::option::Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { let method = path.strip_prefix("anthropic.connectrpc.filter.v1.FilterService/")?; match method { "Redact" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) .with_spec(FILTER_SERVICE_REDACT_SPEC), ) } - _ => None, + _ => ::std::option::Option::None, } } fn call_unary( @@ -251,7 +251,7 @@ impl ::connectrpc::Dispatcher for FilterServiceServer { request: ::connectrpc::Payload, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path + let ::std::option::Option::Some(method) = path .strip_prefix("anthropic.connectrpc.filter.v1.FilterService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; @@ -259,7 +259,7 @@ impl ::connectrpc::Dispatcher for FilterServiceServer { match method { "Redact" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let body = ::connectrpc::dispatcher::codegen::request_proto_bytes::< crate::proto::anthropic::connectrpc::filter::v1::Record, >(request.encoded()?, format)?; @@ -289,7 +289,7 @@ impl ::connectrpc::Dispatcher for FilterServiceServer { request: ::buffa::bytes::Bytes, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path + let ::std::option::Option::Some(method) = path .strip_prefix("anthropic.connectrpc.filter.v1.FilterService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; @@ -305,7 +305,7 @@ impl ::connectrpc::Dispatcher for FilterServiceServer { requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path + let ::std::option::Option::Some(method) = path .strip_prefix("anthropic.connectrpc.filter.v1.FilterService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; @@ -321,7 +321,7 @@ impl ::connectrpc::Dispatcher for FilterServiceServer { requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path + let ::std::option::Option::Some(method) = path .strip_prefix("anthropic.connectrpc.filter.v1.FilterService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; @@ -400,8 +400,10 @@ pub struct FilterServiceClient { impl FilterServiceClient where T: ::connectrpc::client::ClientTransport, - ::Error: Into< - Box, + ::Error: ::std::convert::Into< + ::std::boxed::Box< + dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync, + >, >, { /// Create a new client with the given transport and configuration. @@ -420,7 +422,7 @@ where pub async fn redact( &self, request: crate::proto::anthropic::connectrpc::filter::v1::Record, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::anthropic::connectrpc::filter::v1::__buffa::view::RecordView< @@ -438,7 +440,7 @@ where &self, request: crate::proto::anthropic::connectrpc::filter::v1::Record, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::anthropic::connectrpc::filter::v1::__buffa::view::RecordView< diff --git a/benches/rpc/src/generated/connect/fortune.__connect.rs b/benches/rpc/src/generated/connect/fortune.__connect.rs index 0e58701c..aa5bdad9 100644 --- a/benches/rpc/src/generated/connect/fortune.__connect.rs +++ b/benches/rpc/src/generated/connect/fortune.__connect.rs @@ -98,7 +98,7 @@ pub const FORTUNE_SERVICE_GET_FORTUNES_SPEC: ::connectrpc::Spec = ::connectrpc:: /// [`PreEncoded`](::connectrpc::PreEncoded) — see its `# Streaming /// example` doc. #[allow(clippy::type_complexity)] -pub trait FortuneService: Send + Sync + 'static { +pub trait FortuneService: ::std::marker::Send + ::std::marker::Sync + 'static { /// Handle the GetFortunes RPC. /// /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). @@ -119,9 +119,9 @@ pub trait FortuneService: Send + Sync + 'static { Output = ::connectrpc::ServiceResult< impl ::connectrpc::Encodable< crate::proto::fortune::v1::GetFortunesResponse, - > + Send + use<'a, Self>, + > + ::std::marker::Send + use<'a, Self>, >, - > + Send; + > + ::std::marker::Send; } /// Extension trait for registering a service implementation with a Router. /// @@ -222,7 +222,7 @@ impl FortuneServiceServer { Self { inner } } } -impl Clone for FortuneServiceServer { +impl ::std::clone::Clone for FortuneServiceServer { fn clone(&self) -> Self { Self { inner: ::std::sync::Arc::clone(&self.inner), @@ -234,16 +234,16 @@ impl ::connectrpc::Dispatcher for FortuneServiceServer { fn lookup( &self, path: &str, - ) -> Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { + ) -> ::std::option::Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { let method = path.strip_prefix("fortune.v1.FortuneService/")?; match method { "GetFortunes" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) .with_spec(FORTUNE_SERVICE_GET_FORTUNES_SPEC), ) } - _ => None, + _ => ::std::option::Option::None, } } fn call_unary( @@ -253,14 +253,15 @@ impl ::connectrpc::Dispatcher for FortuneServiceServer { request: ::connectrpc::Payload, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path.strip_prefix("fortune.v1.FortuneService/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("fortune.v1.FortuneService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; let _ = (&ctx, &request, &format); match method { "GetFortunes" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let body = ::connectrpc::dispatcher::codegen::request_proto_bytes::< crate::proto::fortune::v1::GetFortunesRequest, >(request.encoded()?, format)?; @@ -288,7 +289,8 @@ impl ::connectrpc::Dispatcher for FortuneServiceServer { request: ::buffa::bytes::Bytes, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path.strip_prefix("fortune.v1.FortuneService/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("fortune.v1.FortuneService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; let _ = (&ctx, &request, &format); @@ -303,7 +305,8 @@ impl ::connectrpc::Dispatcher for FortuneServiceServer { requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path.strip_prefix("fortune.v1.FortuneService/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("fortune.v1.FortuneService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; let _ = (&ctx, &requests, &format); @@ -318,7 +321,8 @@ impl ::connectrpc::Dispatcher for FortuneServiceServer { requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path.strip_prefix("fortune.v1.FortuneService/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("fortune.v1.FortuneService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; let _ = (&ctx, &requests, &format); @@ -396,8 +400,10 @@ pub struct FortuneServiceClient { impl FortuneServiceClient where T: ::connectrpc::client::ClientTransport, - ::Error: Into< - Box, + ::Error: ::std::convert::Into< + ::std::boxed::Box< + dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync, + >, >, { /// Create a new client with the given transport and configuration. @@ -416,7 +422,7 @@ where pub async fn get_fortunes( &self, request: crate::proto::fortune::v1::GetFortunesRequest, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::fortune::v1::__buffa::view::GetFortunesResponseView< @@ -437,7 +443,7 @@ where &self, request: crate::proto::fortune::v1::GetFortunesRequest, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::fortune::v1::__buffa::view::GetFortunesResponseView< diff --git a/conformance/src/generated/connect/connectrpc.conformance.v1.service.__connect.rs b/conformance/src/generated/connect/connectrpc.conformance.v1.service.__connect.rs index 0c2d4a07..09e71347 100644 --- a/conformance/src/generated/connect/connectrpc.conformance.v1.service.__connect.rs +++ b/conformance/src/generated/connect/connectrpc.conformance.v1.service.__connect.rs @@ -402,7 +402,7 @@ pub const CONFORMANCE_SERVICE_IDEMPOTENT_UNARY_SPEC: ::connectrpc::Spec = ::conn /// [`PreEncoded`](::connectrpc::PreEncoded) — see its `# Streaming /// example` doc. #[allow(clippy::type_complexity)] -pub trait ConformanceService: Send + Sync + 'static { +pub trait ConformanceService: ::std::marker::Send + ::std::marker::Sync + 'static { /// A unary operation. The request indicates the response headers and trailers /// and also indicates either a response message or an error to send back. /// @@ -436,9 +436,9 @@ pub trait ConformanceService: Send + Sync + 'static { Output = ::connectrpc::ServiceResult< impl ::connectrpc::Encodable< crate::proto::connectrpc::conformance::v1::UnaryResponse, - > + Send + use<'a, Self>, + > + ::std::marker::Send + use<'a, Self>, >, - > + Send; + > + ::std::marker::Send; /// A server-streaming operation. The request indicates the response headers, /// response messages, trailers, and an optional error to send back. The /// response data should be sent in the order indicated, and the server should @@ -477,10 +477,10 @@ pub trait ConformanceService: Send + Sync + 'static { ::connectrpc::ServiceStream< impl ::connectrpc::Encodable< crate::proto::connectrpc::conformance::v1::ServerStreamResponse, - > + Send + use, + > + ::std::marker::Send + use, >, >, - > + Send; + > + ::std::marker::Send; /// A client-streaming operation. The first request indicates the response /// headers and trailers and also indicates either a response message or an /// error to send back. @@ -516,9 +516,9 @@ pub trait ConformanceService: Send + Sync + 'static { Output = ::connectrpc::ServiceResult< impl ::connectrpc::Encodable< crate::proto::connectrpc::conformance::v1::ClientStreamResponse, - > + Send + use<'a, Self>, + > + ::std::marker::Send + use<'a, Self>, >, - > + Send; + > + ::std::marker::Send; /// A bidirectional-streaming operation. The first request indicates the response /// headers, response messages, trailers, and an optional error to send back. /// The response data should be sent in the order indicated, and the server @@ -582,10 +582,10 @@ pub trait ConformanceService: Send + Sync + 'static { ::connectrpc::ServiceStream< impl ::connectrpc::Encodable< crate::proto::connectrpc::conformance::v1::BidiStreamResponse, - > + Send + use, + > + ::std::marker::Send + use, >, >, - > + Send; + > + ::std::marker::Send; /// A unary endpoint that the server should not implement and should instead /// return an unimplemented error when invoked. /// @@ -607,9 +607,9 @@ pub trait ConformanceService: Send + Sync + 'static { Output = ::connectrpc::ServiceResult< impl ::connectrpc::Encodable< crate::proto::connectrpc::conformance::v1::UnimplementedResponse, - > + Send + use<'a, Self>, + > + ::std::marker::Send + use<'a, Self>, >, - > + Send; + > + ::std::marker::Send; /// A unary endpoint denoted as having no side effects (i.e. idempotent). /// Implementations should use an HTTP GET when invoking this endpoint and /// leverage query parameters to send data. @@ -632,9 +632,9 @@ pub trait ConformanceService: Send + Sync + 'static { Output = ::connectrpc::ServiceResult< impl ::connectrpc::Encodable< crate::proto::connectrpc::conformance::v1::IdempotentUnaryResponse, - > + Send + use<'a, Self>, + > + ::std::marker::Send + use<'a, Self>, >, - > + Send; + > + ::std::marker::Send; } /// Extension trait for registering a service implementation with a Router. /// @@ -865,7 +865,7 @@ impl ConformanceServiceServer { Self { inner } } } -impl Clone for ConformanceServiceServer { +impl ::std::clone::Clone for ConformanceServiceServer { fn clone(&self) -> Self { Self { inner: ::std::sync::Arc::clone(&self.inner), @@ -877,46 +877,46 @@ impl ::connectrpc::Dispatcher for ConformanceServiceServe fn lookup( &self, path: &str, - ) -> Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { + ) -> ::std::option::Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { let method = path.strip_prefix("connectrpc.conformance.v1.ConformanceService/")?; match method { "Unary" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) .with_spec(CONFORMANCE_SERVICE_UNARY_SPEC), ) } "ServerStream" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::server_streaming() .with_spec(CONFORMANCE_SERVICE_SERVER_STREAM_SPEC), ) } "ClientStream" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::client_streaming() .with_spec(CONFORMANCE_SERVICE_CLIENT_STREAM_SPEC), ) } "BidiStream" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::bidi_streaming() .with_spec(CONFORMANCE_SERVICE_BIDI_STREAM_SPEC), ) } "Unimplemented" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) .with_spec(CONFORMANCE_SERVICE_UNIMPLEMENTED_SPEC), ) } "IdempotentUnary" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(true) .with_spec(CONFORMANCE_SERVICE_IDEMPOTENT_UNARY_SPEC), ) } - _ => None, + _ => ::std::option::Option::None, } } fn call_unary( @@ -926,7 +926,7 @@ impl ::connectrpc::Dispatcher for ConformanceServiceServe request: ::connectrpc::Payload, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path + let ::std::option::Option::Some(method) = path .strip_prefix("connectrpc.conformance.v1.ConformanceService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; @@ -934,7 +934,7 @@ impl ::connectrpc::Dispatcher for ConformanceServiceServe match method { "Unary" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let body = ::connectrpc::dispatcher::codegen::request_proto_bytes::< crate::proto::connectrpc::conformance::v1::UnaryRequest, >(request.encoded()?, format)?; @@ -956,7 +956,7 @@ impl ::connectrpc::Dispatcher for ConformanceServiceServe } "Unimplemented" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let body = ::connectrpc::dispatcher::codegen::request_proto_bytes::< crate::proto::connectrpc::conformance::v1::UnimplementedRequest, >(request.encoded()?, format)?; @@ -978,7 +978,7 @@ impl ::connectrpc::Dispatcher for ConformanceServiceServe } "IdempotentUnary" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let body = ::connectrpc::dispatcher::codegen::request_proto_bytes::< crate::proto::connectrpc::conformance::v1::IdempotentUnaryRequest, >(request.encoded()?, format)?; @@ -1008,7 +1008,7 @@ impl ::connectrpc::Dispatcher for ConformanceServiceServe request: ::buffa::bytes::Bytes, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path + let ::std::option::Option::Some(method) = path .strip_prefix("connectrpc.conformance.v1.ConformanceService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; @@ -1016,7 +1016,7 @@ impl ::connectrpc::Dispatcher for ConformanceServiceServe match method { "ServerStream" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let body = ::connectrpc::dispatcher::codegen::request_proto_bytes::< crate::proto::connectrpc::conformance::v1::ServerStreamRequest, >(request, format)?; @@ -1030,7 +1030,7 @@ impl ::connectrpc::Dispatcher for ConformanceServiceServe crate::proto::connectrpc::conformance::v1::ServerStreamRequest, >::from_parts(&req, &body); let resp = svc.server_stream(ctx, req).await?; - Ok( + ::std::result::Result::Ok( resp .map_body(|s| ::connectrpc::dispatcher::codegen::encode_response_stream::< crate::proto::connectrpc::conformance::v1::ServerStreamResponse, @@ -1050,7 +1050,7 @@ impl ::connectrpc::Dispatcher for ConformanceServiceServe requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path + let ::std::option::Option::Some(method) = path .strip_prefix("connectrpc.conformance.v1.ConformanceService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; @@ -1058,7 +1058,7 @@ impl ::connectrpc::Dispatcher for ConformanceServiceServe match method { "ClientStream" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let req_stream = ::connectrpc::dispatcher::codegen::decode_message_request_stream::< crate::proto::connectrpc::conformance::v1::ClientStreamRequest, >(requests, format, ctx.decode_options().clone()); @@ -1079,7 +1079,7 @@ impl ::connectrpc::Dispatcher for ConformanceServiceServe requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path + let ::std::option::Option::Some(method) = path .strip_prefix("connectrpc.conformance.v1.ConformanceService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; @@ -1087,12 +1087,12 @@ impl ::connectrpc::Dispatcher for ConformanceServiceServe match method { "BidiStream" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let req_stream = ::connectrpc::dispatcher::codegen::decode_message_request_stream::< crate::proto::connectrpc::conformance::v1::BidiStreamRequest, >(requests, format, ctx.decode_options().clone()); let resp = svc.bidi_stream(ctx, req_stream).await?; - Ok( + ::std::result::Result::Ok( resp .map_body(|s| ::connectrpc::dispatcher::codegen::encode_response_stream::< crate::proto::connectrpc::conformance::v1::BidiStreamResponse, @@ -1175,8 +1175,10 @@ pub struct ConformanceServiceClient { impl ConformanceServiceClient where T: ::connectrpc::client::ClientTransport, - ::Error: Into< - Box, + ::Error: ::std::convert::Into< + ::std::boxed::Box< + dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync, + >, >, { /// Create a new client with the given transport and configuration. @@ -1195,7 +1197,7 @@ where pub async fn unary( &self, request: crate::proto::connectrpc::conformance::v1::UnaryRequest, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::connectrpc::conformance::v1::__buffa::view::UnaryResponseView< @@ -1213,7 +1215,7 @@ where &self, request: crate::proto::connectrpc::conformance::v1::UnaryRequest, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::connectrpc::conformance::v1::__buffa::view::UnaryResponseView< @@ -1237,7 +1239,7 @@ where pub async fn server_stream( &self, request: crate::proto::connectrpc::conformance::v1::ServerStreamRequest, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::ServerStream< T::ResponseBody, crate::proto::connectrpc::conformance::v1::__buffa::view::ServerStreamResponseView< @@ -1257,7 +1259,7 @@ where &self, request: crate::proto::connectrpc::conformance::v1::ServerStreamRequest, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::ServerStream< T::ResponseBody, crate::proto::connectrpc::conformance::v1::__buffa::view::ServerStreamResponseView< @@ -1295,7 +1297,7 @@ where requests: impl ::connectrpc::client::ClientRequestStream< crate::proto::connectrpc::conformance::v1::ClientStreamRequest, >, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::connectrpc::conformance::v1::__buffa::view::ClientStreamResponseView< @@ -1331,7 +1333,7 @@ where crate::proto::connectrpc::conformance::v1::ClientStreamRequest, >, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::connectrpc::conformance::v1::__buffa::view::ClientStreamResponseView< @@ -1354,7 +1356,7 @@ where /// Call the BidiStream RPC. Sends a request to /connectrpc.conformance.v1.ConformanceService/BidiStream. pub async fn bidi_stream( &self, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::BidiStream< T::ResponseBody, crate::proto::connectrpc::conformance::v1::BidiStreamRequest, @@ -1370,7 +1372,7 @@ where pub async fn bidi_stream_with_options( &self, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::BidiStream< T::ResponseBody, crate::proto::connectrpc::conformance::v1::BidiStreamRequest, @@ -1393,7 +1395,7 @@ where pub async fn unimplemented( &self, request: crate::proto::connectrpc::conformance::v1::UnimplementedRequest, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::connectrpc::conformance::v1::__buffa::view::UnimplementedResponseView< @@ -1414,7 +1416,7 @@ where &self, request: crate::proto::connectrpc::conformance::v1::UnimplementedRequest, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::connectrpc::conformance::v1::__buffa::view::UnimplementedResponseView< @@ -1438,7 +1440,7 @@ where pub async fn idempotent_unary( &self, request: crate::proto::connectrpc::conformance::v1::IdempotentUnaryRequest, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::connectrpc::conformance::v1::__buffa::view::IdempotentUnaryResponseView< @@ -1459,7 +1461,7 @@ where &self, request: crate::proto::connectrpc::conformance::v1::IdempotentUnaryRequest, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::connectrpc::conformance::v1::__buffa::view::IdempotentUnaryResponseView< diff --git a/connectrpc-codegen/src/codegen.rs b/connectrpc-codegen/src/codegen.rs index 75d745f8..8d34fca5 100644 --- a/connectrpc-codegen/src/codegen.rs +++ b/connectrpc-codegen/src/codegen.rs @@ -777,7 +777,7 @@ fn doc_attrs(text: &str) -> TokenStream { /// service method input/output types resolve to the same paths buffa-codegen /// emits for message fields — including cross-package (`super::foo::Bar`), /// WKT extern paths (`::buffa_types::google::protobuf::Empty`), and nested -/// types (`outer::Inner`). Zero drift with buffa's own generation. +/// types (`outer::Inner`). The one difference is [`module_qualified`]. struct TypeResolver<'a> { ctx: buffa_codegen::context::CodeGenContext<'a>, /// When true, every resolved path must be absolute (`::foo` or @@ -806,7 +806,8 @@ impl<'a> TypeResolver<'a> { } /// Resolve a proto FQN (e.g. `.google.protobuf.Empty`) to a Rust type-path - /// string relative to `current_package`. + /// string relative to `current_package`, passed through + /// [`module_qualified`]. /// /// Errors if the type is absent from the descriptor set, and — in /// `require_extern` mode — if the resolved path is not absolute. @@ -814,7 +815,7 @@ impl<'a> TypeResolver<'a> { match self.ctx.rust_type_relative(proto_fqn, current_package, 0) { Some(path) => { self.check_extern_coverage(proto_fqn, &path)?; - Ok(path) + Ok(module_qualified(path)) } None => Err(self.unresolved_type_error(proto_fqn)), } @@ -884,7 +885,31 @@ impl<'a> TypeResolver<'a> { } else { format!("{to_package}::{SENTINEL_MOD}::view") }; - Ok(rust_path_to_tokens(&format!("{prefix}::{within}View"))) + Ok(rust_path_to_tokens(&module_qualified(format!( + "{prefix}::{within}View" + )))) + } +} + +/// Every generic type parameter the templates declare. The templates spell them +/// literally; the `stubs_resolve_only_their_own_names` test fails if one is +/// added without being listed here. +const GENERIC_PARAMS: [&str; 2] = ["S", "T"]; + +/// Prefix `self::` to a path whose first segment is one of +/// [`GENERIC_PARAMS`], and return every other path unchanged. +/// +/// Inside `impl` the bare name `T` is the parameter, so `message T` (or +/// `service T`, or a sub-package `T`) has to be reached through the module. +/// Renaming the parameters instead would change the rustdoc of every +/// generated client and server, and would leave the new names open to the +/// same collision. +fn module_qualified(path: String) -> String { + let first = path.split("::").next().unwrap_or_default(); + if GENERIC_PARAMS.contains(&first) { + format!("self::{path}") + } else { + path } } @@ -963,10 +988,15 @@ fn generate_connect_services( ) -> Result { let mut tokens = TokenStream::new(); - // All types in generated code use fully qualified paths (e.g. - // `::std::sync::Arc`, `::connectrpc::Context`) so that multiple service - // files can be `include!`d into the same module without E0252 duplicate - // import errors. + // Generated code reaches everything it does not declare itself through a + // `::`-rooted path (`::std::sync::Arc`, `::connectrpc::RequestContext`), + // for two reasons. Multiple service files can be `include!`d into the + // same module without E0252 duplicate import errors. And the prelude is + // not reliable there: the module declares the package's service traits + // (in the unified layout, its messages and enums too) and glob-imports + // its parent modules. So `message Result` or `service Send`, in this + // package or a parent package, takes the place of the prelude item, as + // does `use anyhow::Ok;` in the module that hosts the generated code. // The view-family impls (`buffa::HasMessageView`) are emitted by buffa's // own codegen alongside each message's view and owned-view wrapper, so @@ -1492,6 +1522,8 @@ fn generate_service( server_name, service_name_const, } = idents; + // How the `impl` and `impl` blocks name the trait. + let trait_path = rust_path_to_tokens(&module_qualified(trait_name.to_string())); // Get service documentation and append async impl guidance let service_doc = get_service_comment(file, service).unwrap_or_default(); @@ -1709,6 +1741,7 @@ fn generate_service( let service_server = generate_service_server( &full_service_name, &trait_name, + &trait_path, &server_name, service, resolver, @@ -1821,7 +1854,7 @@ methods (`msg.name()`) or `.view()`, or convert with `.to_owned_message()`."# #service_doc_tokens #[allow(clippy::type_complexity)] - pub trait #trait_name: Send + Sync + 'static { + pub trait #trait_name: ::std::marker::Send + ::std::marker::Sync + 'static { #(#trait_methods)* } @@ -1848,7 +1881,7 @@ methods (`msg.name()`) or `.view()`, or convert with `.to_owned_message()`."# fn register(self: ::std::sync::Arc, router: ::connectrpc::Router) -> ::connectrpc::Router; } - impl #ext_trait_name for S { + impl #ext_trait_name for S { fn register(self: ::std::sync::Arc, router: ::connectrpc::Router) -> ::connectrpc::Router { router #(#route_registrations)* @@ -1859,7 +1892,7 @@ methods (`msg.name()`) or `.view()`, or convert with `.to_owned_message()`."# #[doc(hidden)] pub struct #register_marker_name; - impl ::connectrpc::ServiceRegister<#register_marker_name> + impl ::connectrpc::ServiceRegister<#register_marker_name> for ::std::sync::Arc { fn register_service(self, router: ::connectrpc::Router) -> ::connectrpc::Router { @@ -1881,7 +1914,7 @@ methods (`msg.name()`) or `.view()`, or convert with `.to_owned_message()`."# impl #client_name where T: ::connectrpc::client::ClientTransport, - ::Error: Into>, + ::Error: ::std::convert::Into<::std::boxed::Box>, { /// Create a new client with the given transport and configuration. pub fn new(transport: T, config: ::connectrpc::client::ClientConfig) -> Self { @@ -1976,6 +2009,7 @@ fn generate_spec_consts( fn generate_service_server( full_service_name: &str, trait_name: &proc_macro2::Ident, + trait_path: &TokenStream, server_name: &proc_macro2::Ident, service: &ServiceDescriptorProto, resolver: &TypeResolver<'_>, @@ -2008,7 +2042,7 @@ fn generate_service_server( } else { quote! { ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(#is_idempotent) } }; - quote! { #method_name => Some(#desc.with_spec(#spec_const)), } + quote! { #method_name => ::std::option::Option::Some(#desc.with_spec(#spec_const)), } }) .collect(); @@ -2042,10 +2076,10 @@ fn generate_service_server( call_bidi_arms.push(quote! { #method_name => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let req_stream = #stream_decode; let resp = svc.#method_snake(ctx, req_stream).await?; - Ok(resp.map_body(|s| ::connectrpc::dispatcher::codegen::encode_response_stream::<#output_type, _, _>(s, format))) + ::std::result::Result::Ok(resp.map_body(|s| ::connectrpc::dispatcher::codegen::encode_response_stream::<#output_type, _, _>(s, format))) }) } }); @@ -2054,7 +2088,7 @@ fn generate_service_server( call_cs_arms.push(quote! { #method_name => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let req_stream = #stream_decode; svc.#method_snake(ctx, req_stream).await?.encode::<#output_type>(format) }) @@ -2071,13 +2105,13 @@ fn generate_service_server( call_ss_arms.push(quote! { #method_name => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { // The normalized body is owned by this future; the handler // borrows from it until it returns the response stream. let body = ::connectrpc::dispatcher::codegen::request_proto_bytes::<#input_owned>(request, format)?; let req: #input_view<'_> = ::connectrpc::dispatcher::codegen::decode_borrowed_request_view(&body, ctx.decode_options())?; #call_handler - Ok(resp.map_body(|s| ::connectrpc::dispatcher::codegen::encode_response_stream::<#output_type, _, _>(s, format))) + ::std::result::Result::Ok(resp.map_body(|s| ::connectrpc::dispatcher::codegen::encode_response_stream::<#output_type, _, _>(s, format))) }) } }); @@ -2092,7 +2126,7 @@ fn generate_service_server( call_unary_arms.push(quote! { #method_name => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { // Generated handlers are view-based, so the owned-message // cache an interceptor may have populated cannot be reused. // `encoded()` returns the (post-replacement) wire bytes — @@ -2129,7 +2163,7 @@ fn generate_service_server( inner: ::std::sync::Arc, } - impl #server_name { + impl #server_name { /// Wrap a service implementation in a monomorphic dispatcher. pub fn new(service: T) -> Self { Self { inner: ::std::sync::Arc::new(service) } @@ -2141,19 +2175,19 @@ fn generate_service_server( } } - impl Clone for #server_name { + impl ::std::clone::Clone for #server_name { fn clone(&self) -> Self { Self { inner: ::std::sync::Arc::clone(&self.inner) } } } - impl ::connectrpc::Dispatcher for #server_name { + impl ::connectrpc::Dispatcher for #server_name { #[inline] - fn lookup(&self, path: &str) -> Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { + fn lookup(&self, path: &str) -> ::std::option::Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { let method = path.strip_prefix(#path_prefix)?; match method { #(#lookup_arms)* - _ => None, + _ => ::std::option::Option::None, } } @@ -2164,7 +2198,7 @@ fn generate_service_server( request: ::connectrpc::Payload, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path.strip_prefix(#path_prefix) else { + let ::std::option::Option::Some(method) = path.strip_prefix(#path_prefix) else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; // Suppress unused warnings when this service has no unary methods. @@ -2182,7 +2216,7 @@ fn generate_service_server( request: ::buffa::bytes::Bytes, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path.strip_prefix(#path_prefix) else { + let ::std::option::Option::Some(method) = path.strip_prefix(#path_prefix) else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; let _ = (&ctx, &request, &format); @@ -2199,7 +2233,7 @@ fn generate_service_server( requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path.strip_prefix(#path_prefix) else { + let ::std::option::Option::Some(method) = path.strip_prefix(#path_prefix) else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; let _ = (&ctx, &requests, &format); @@ -2216,7 +2250,7 @@ fn generate_service_server( requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path.strip_prefix(#path_prefix) else { + let ::std::option::Option::Some(method) = path.strip_prefix(#path_prefix) else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; let _ = (&ctx, &requests, &format); @@ -2290,7 +2324,7 @@ fn generate_trait_method( &self, ctx: ::connectrpc::RequestContext, request: #request_param, - ) -> impl ::std::future::Future + Send + use>>> + Send; + ) -> impl ::std::future::Future + ::std::marker::Send + use>>> + ::std::marker::Send; }) } else if client_streaming && !server_streaming { // Client streaming method. Inbound items are `StreamMessage` — @@ -2308,7 +2342,7 @@ fn generate_trait_method( &'a self, ctx: ::connectrpc::RequestContext, requests: ::connectrpc::InboundStream<#stream_owned>, - ) -> impl ::std::future::Future + Send + use<'a, Self>>> + Send; + ) -> impl ::std::future::Future + ::std::marker::Send + use<'a, Self>>> + ::std::marker::Send; }) } else if client_streaming && server_streaming { // Bidi streaming method. Same `impl Encodable<...>` item type and @@ -2323,7 +2357,7 @@ fn generate_trait_method( &self, ctx: ::connectrpc::RequestContext, requests: ::connectrpc::InboundStream<#stream_owned>, - ) -> impl ::std::future::Future + Send + use>>> + Send; + ) -> impl ::std::future::Future + ::std::marker::Send + use>>> + ::std::marker::Send; }) } else { // Unary method. The request is *borrowed*: the generated dispatcher @@ -2355,7 +2389,7 @@ fn generate_trait_method( &'a self, ctx: ::connectrpc::RequestContext, request: #request_param, - ) -> impl ::std::future::Future + Send + use<'a, Self>>> + Send; + ) -> impl ::std::future::Future + ::std::marker::Send + use<'a, Self>>> + ::std::marker::Send; }) } } @@ -2426,7 +2460,7 @@ fn generate_client_method( #[doc = " than, say, wrapping it in a `timeout`."] }; ret_ty = quote! { - Result< + ::std::result::Result< ::connectrpc::client::UnaryResponse<::buffa::view::OwnedView<#output_view_type<'static>>>, ::connectrpc::ConnectError, > @@ -2445,7 +2479,7 @@ fn generate_client_method( } else if client_streaming && server_streaming { // Bidi ret_ty = quote! { - Result< + ::std::result::Result< ::connectrpc::client::BidiStream< T::ResponseBody, #input_type, #output_view_type<'static> >, @@ -2464,7 +2498,7 @@ fn generate_client_method( } else if server_streaming { // Server-stream ret_ty = quote! { - Result< + ::std::result::Result< ::connectrpc::client::ServerStream>, ::connectrpc::ConnectError, > @@ -2482,7 +2516,7 @@ fn generate_client_method( } else { // Unary ret_ty = quote! { - Result< + ::std::result::Result< ::connectrpc::client::UnaryResponse<::buffa::view::OwnedView<#output_view_type<'static>>>, ::connectrpc::ConnectError, > @@ -3048,7 +3082,7 @@ mod tests { // Trait method declares `ServiceStream + ...>`. assert_eq!( - code.matches(":: connectrpc :: ServiceStream < impl :: connectrpc :: Encodable < Resp > + Send + use < Self >>") + code.matches(":: connectrpc :: ServiceStream < impl :: connectrpc :: Encodable < Resp > + :: std :: marker :: Send + use < Self >>") .count(), 2, "server-streaming and bidi should both use the Encodable item type: {code}" @@ -5245,6 +5279,223 @@ mod tests { assert_no_top_level_use(&formatted_b, "service B"); } + /// Build a proto file in package `pkg` with one service that has an RPC + /// of each of the four shapes, all typed `input` -> `output` (bare + /// message names, declared in the file). + fn four_shape_file(service: &str, input: &str, output: &str) -> FileDescriptorProto { + let method = + |name: &str, client_streaming: bool, server_streaming: bool| MethodDescriptorProto { + name: Some(name.into()), + input_type: Some(format!(".pkg.{input}")), + output_type: Some(format!(".pkg.{output}")), + client_streaming: Some(client_streaming), + server_streaming: Some(server_streaming), + ..Default::default() + }; + FileDescriptorProto { + name: Some("pkg.proto".into()), + package: Some("pkg".into()), + message_type: [input, output] + .into_iter() + .map(|name| DescriptorProto { + name: Some(name.into()), + ..Default::default() + }) + .collect(), + service: vec![ServiceDescriptorProto { + name: Some(service.into()), + method: vec![ + method("Unary", false, false), + method("ServerStream", false, true), + method("ClientStream", true, false), + method("Bidi", true, true), + ], + ..Default::default() + }], + ..Default::default() + } + } + + /// Collect the identifiers in `tokens` that are looked up in the enclosing + /// scope as a type, trait, module or constructor. An identifier counts + /// when the token before it is something other than `::` or a single `.`, + /// and it is capitalized or starts a path. Keywords are skipped, `self`, + /// `Self`, `super` and `crate` among them. + /// + /// Attributes are skipped: doc text is not code, and `derive(Clone)` + /// resolves `Clone` as a macro, which a proto cannot declare. A path in + /// an attribute (`#[tracing::instrument]`) has to be `::`-rooted by hand. + fn scope_resolved_idents(tokens: TokenStream, out: &mut std::collections::BTreeSet) { + use proc_macro2::{Spacing, TokenTree}; + + // The punctuation run that ends just before the current token, which + // tells `::` (a path) from `:` (a bound or a type), and `.` (a field + // or method) from `..` (a range or struct update). + let mut prev = String::new(); + let mut tokens = tokens.into_iter().peekable(); + while let Some(tree) = tokens.next() { + match tree { + TokenTree::Punct(punct) => { + prev.push(punct.as_char()); + continue; + } + TokenTree::Group(_) if prev.ends_with('#') => {} + TokenTree::Group(group) => scope_resolved_idents(group.stream(), out), + TokenTree::Ident(ident) => { + let member = prev.ends_with('.') && !prev.ends_with(".."); + let starts_path = matches!( + tokens.peek(), + Some(TokenTree::Punct(p)) if p.as_char() == ':' && p.spacing() == Spacing::Joint + ); + let name = ident.to_string(); + if !member + && !prev.ends_with("::") + && !buffa_codegen::idents::is_rust_keyword(&name) + && (starts_path || name.starts_with(char::is_uppercase)) + { + out.insert(name); + } + } + TokenTree::Literal(_) => {} + } + prev.clear(); + } + } + + #[test] + fn scope_resolved_idents_finds_each_position() { + let mut idents = std::collections::BTreeSet::new(); + scope_resolved_idents( + quote! { + #[derive(Skipped)] + fn f(a: &A) -> impl B + use<'a, C> where ::Skipped: dyn F { + let G(x) = g::(I { x, ..J::default() }); + k::Skipped::skipped(x.Skipped, ::skipped::Skipped, self::Skipped, 0..L); + r#type::Skipped(Self::Skipped) + } + }, + &mut idents, + ); + let found: String = idents.into_iter().collect(); + assert_eq!(found, "ABCDEFGHIJLgkr#type"); + } + + /// Fails when a template names anything it does not declare itself without + /// a `::` root; `generate_connect_services` says why. Primitives are not + /// covered: `str` stays bare, as it does in buffa's output. + #[test] + fn stubs_resolve_only_their_own_names() { + let file = four_shape_file("ZzSvc", "ZzReq", "ZzResp"); + let config = buffa_codegen::CodeGenConfig::default(); + let targets = ["pkg.proto".to_string()]; + let resolver = TypeResolver::new(std::slice::from_ref(&file), &targets, &config, false); + let mut batch = BatchState { + all_message_encodable_impls: true, + ..BatchState::default() + }; + let code = generate_connect_services(&file, &resolver, &mut batch).unwrap(); + + let mut idents = std::collections::BTreeSet::new(); + scope_resolved_idents(code, &mut idents); + // The fixture's own names, and what is derived from them. + idents.retain(|name| !name.contains("Zz") && !name.starts_with("ZZ_")); + // `Output` is the binding in `Future`, which is looked up + // in the trait. `__buffa` is the module buffa reserves in each package. + for declared in ["Output", "__buffa"].iter().chain(&GENERIC_PARAMS) { + idents.remove(*declared); + } + assert!( + idents.is_empty(), + "{idents:?} can be shadowed in the module that includes the stubs: write a \ + `::`-rooted path, or list a new generic parameter in GENERIC_PARAMS" + ); + } + + #[test] + fn module_qualified_matches_the_first_segment_only() { + for (path, expected) in [ + ("S", "self::S"), + ("T", "self::T"), + ("T::Msg", "self::T::Msg"), + ("Sx", "Sx"), + ("s::T", "s::T"), + ("super::T", "super::T"), + ("crate::T", "crate::T"), + ("::T::X", "::T::X"), + ] { + assert_eq!(module_qualified(path.into()), expected); + } + } + + #[test] + fn types_named_like_generic_params_are_module_qualified() { + let code = gen_file(&[four_shape_file("Svc", "S", "T")], 0, &[], false).unwrap(); + assert!( + code.contains(":: connectrpc :: ServiceRequest < '_ , self :: S >"), + "input type not qualified: {code}" + ); + assert!( + code.contains(":: connectrpc :: Encodable < self :: T >"), + "output type not qualified: {code}" + ); + assert!( + code.contains("async fn unary (& self , request : self :: S)"), + "client request type not qualified: {code}" + ); + + for service in ["S", "T"] { + let file = four_shape_file(service, "Req", "Resp"); + let code = gen_file(&[file], 0, &[], false).unwrap(); + for bound in [ + format!("impl < S : self :: {service} > {service}Ext for S"), + format!("impl < T : self :: {service} > {service}Server < T >"), + ] { + assert!(code.contains(&bound), "missing `{bound}`: {code}"); + } + } + + // A sub-package starts the path of its types and views. + let sub = FileDescriptorProto { + name: Some("sub.proto".into()), + package: Some("pkg.T".into()), + message_type: vec![DescriptorProto { + name: Some("Msg".into()), + ..Default::default() + }], + ..Default::default() + }; + let mut file = four_shape_file("Svc", "Req", "Resp"); + for method in &mut file.service[0].method { + method.input_type = Some(".pkg.T.Msg".into()); + } + let code = gen_file(&[sub, file], 1, &[], false).unwrap(); + assert!( + code.contains("ServiceRequest < '_ , self :: T :: Msg >"), + "sub-package type not qualified: {code}" + ); + assert!( + code.contains("self :: T :: __buffa :: view :: MsgView"), + "sub-package view not qualified: {code}" + ); + + // In the split layout the messages are reached from the crate root, + // and the trait is still declared beside the stubs. + let extern_paths = [(".".to_string(), "crate::proto".to_string())]; + let code = gen_file(&[four_shape_file("T", "S", "Resp")], 0, &extern_paths, true).unwrap(); + assert!( + code.contains("impl < T : self :: T > TServer < T >"), + "split-layout trait not qualified: {code}" + ); + assert!( + code.contains("ServiceRequest < '_ , crate :: proto :: pkg :: S >"), + "split-layout type changed: {code}" + ); + + // Every other name keeps its bare form. + let code = gen_file(&[four_shape_file("Svc", "Req", "Resp")], 0, &[], false).unwrap(); + assert!(!code.contains("self ::"), "unexpected `self::`: {code}"); + } + /// `generate_spec_consts` emits one `pub const … : Spec` per method, /// named `{SERVICE}_{METHOD}_SPEC`, with the right `StreamType`, /// `IdempotencyLevel`, and procedure path. diff --git a/connectrpc-health/src/generated/connect/grpc.health.v1.health.__connect.rs b/connectrpc-health/src/generated/connect/grpc.health.v1.health.__connect.rs index 1213942f..16a8b855 100644 --- a/connectrpc-health/src/generated/connect/grpc.health.v1.health.__connect.rs +++ b/connectrpc-health/src/generated/connect/grpc.health.v1.health.__connect.rs @@ -104,7 +104,7 @@ pub const HEALTH_WATCH_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server( /// [`PreEncoded`](::connectrpc::PreEncoded) — see its `# Streaming /// example` doc. #[allow(clippy::type_complexity)] -pub trait Health: Send + Sync + 'static { +pub trait Health: ::std::marker::Send + ::std::marker::Sync + 'static { /// Check returns the serving status of the requested service. If the /// service name is empty, the response covers the whole server. /// @@ -126,9 +126,9 @@ pub trait Health: Send + Sync + 'static { Output = ::connectrpc::ServiceResult< impl ::connectrpc::Encodable< crate::proto::grpc::health::v1::HealthCheckResponse, - > + Send + use<'a, Self>, + > + ::std::marker::Send + use<'a, Self>, >, - > + Send; + > + ::std::marker::Send; /// Watch performs a watch for the serving status of the requested service. /// The server will immediately send back a message indicating the current /// serving status. It will then subsequently send a new message whenever @@ -162,10 +162,10 @@ pub trait Health: Send + Sync + 'static { ::connectrpc::ServiceStream< impl ::connectrpc::Encodable< crate::proto::grpc::health::v1::HealthCheckResponse, - > + Send + use, + > + ::std::marker::Send + use, >, >, - > + Send; + > + ::std::marker::Send; } /// Extension trait for registering a service implementation with a Router. /// @@ -294,7 +294,7 @@ impl HealthServer { Self { inner } } } -impl Clone for HealthServer { +impl ::std::clone::Clone for HealthServer { fn clone(&self) -> Self { Self { inner: ::std::sync::Arc::clone(&self.inner), @@ -306,22 +306,22 @@ impl ::connectrpc::Dispatcher for HealthServer { fn lookup( &self, path: &str, - ) -> Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { + ) -> ::std::option::Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { let method = path.strip_prefix("grpc.health.v1.Health/")?; match method { "Check" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) .with_spec(HEALTH_CHECK_SPEC), ) } "Watch" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::server_streaming() .with_spec(HEALTH_WATCH_SPEC), ) } - _ => None, + _ => ::std::option::Option::None, } } fn call_unary( @@ -331,14 +331,15 @@ impl ::connectrpc::Dispatcher for HealthServer { request: ::connectrpc::Payload, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path.strip_prefix("grpc.health.v1.Health/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("grpc.health.v1.Health/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; let _ = (&ctx, &request, &format); match method { "Check" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let body = ::connectrpc::dispatcher::codegen::request_proto_bytes::< crate::proto::grpc::health::v1::HealthCheckRequest, >(request.encoded()?, format)?; @@ -368,14 +369,15 @@ impl ::connectrpc::Dispatcher for HealthServer { request: ::buffa::bytes::Bytes, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path.strip_prefix("grpc.health.v1.Health/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("grpc.health.v1.Health/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; let _ = (&ctx, &request, &format); match method { "Watch" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let body = ::connectrpc::dispatcher::codegen::request_proto_bytes::< crate::proto::grpc::health::v1::HealthCheckRequest, >(request, format)?; @@ -389,7 +391,7 @@ impl ::connectrpc::Dispatcher for HealthServer { crate::proto::grpc::health::v1::HealthCheckRequest, >::from_parts(&req, &body); let resp = svc.watch(ctx, req).await?; - Ok( + ::std::result::Result::Ok( resp .map_body(|s| ::connectrpc::dispatcher::codegen::encode_response_stream::< crate::proto::grpc::health::v1::HealthCheckResponse, @@ -409,7 +411,8 @@ impl ::connectrpc::Dispatcher for HealthServer { requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path.strip_prefix("grpc.health.v1.Health/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("grpc.health.v1.Health/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; let _ = (&ctx, &requests, &format); @@ -424,7 +427,8 @@ impl ::connectrpc::Dispatcher for HealthServer { requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path.strip_prefix("grpc.health.v1.Health/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("grpc.health.v1.Health/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; let _ = (&ctx, &requests, &format); @@ -504,8 +508,10 @@ pub struct HealthClient { impl HealthClient where T: ::connectrpc::client::ClientTransport, - ::Error: Into< - Box, + ::Error: ::std::convert::Into< + ::std::boxed::Box< + dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync, + >, >, { /// Create a new client with the given transport and configuration. @@ -524,7 +530,7 @@ where pub async fn check( &self, request: crate::proto::grpc::health::v1::HealthCheckRequest, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::grpc::health::v1::__buffa::view::HealthCheckResponseView< @@ -542,7 +548,7 @@ where &self, request: crate::proto::grpc::health::v1::HealthCheckRequest, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::grpc::health::v1::__buffa::view::HealthCheckResponseView< @@ -565,7 +571,7 @@ where pub async fn watch( &self, request: crate::proto::grpc::health::v1::HealthCheckRequest, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::ServerStream< T::ResponseBody, crate::proto::grpc::health::v1::__buffa::view::HealthCheckResponseView< @@ -582,7 +588,7 @@ where &self, request: crate::proto::grpc::health::v1::HealthCheckRequest, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::ServerStream< T::ResponseBody, crate::proto::grpc::health::v1::__buffa::view::HealthCheckResponseView< diff --git a/connectrpc-reflection/src/generated/connect/grpc.reflection.v1.reflection.__connect.rs b/connectrpc-reflection/src/generated/connect/grpc.reflection.v1.reflection.__connect.rs index 375fe1fa..0dde31eb 100644 --- a/connectrpc-reflection/src/generated/connect/grpc.reflection.v1.reflection.__connect.rs +++ b/connectrpc-reflection/src/generated/connect/grpc.reflection.v1.reflection.__connect.rs @@ -108,7 +108,7 @@ pub const SERVER_REFLECTION_SERVER_REFLECTION_INFO_SPEC: ::connectrpc::Spec = :: /// [`PreEncoded`](::connectrpc::PreEncoded) — see its `# Streaming /// example` doc. #[allow(clippy::type_complexity)] -pub trait ServerReflection: Send + Sync + 'static { +pub trait ServerReflection: ::std::marker::Send + ::std::marker::Sync + 'static { /// The reflection service is structured as a bidirectional stream, ensuring /// all related requests go to a single server. /// @@ -127,10 +127,10 @@ pub trait ServerReflection: Send + Sync + 'static { ::connectrpc::ServiceStream< impl ::connectrpc::Encodable< crate::proto::grpc::reflection::v1::ServerReflectionResponse, - > + Send + use, + > + ::std::marker::Send + use, >, >, - > + Send; + > + ::std::marker::Send; } /// Extension trait for registering a service implementation with a Router. /// @@ -223,7 +223,7 @@ impl ServerReflectionServer { Self { inner } } } -impl Clone for ServerReflectionServer { +impl ::std::clone::Clone for ServerReflectionServer { fn clone(&self) -> Self { Self { inner: ::std::sync::Arc::clone(&self.inner), @@ -235,16 +235,16 @@ impl ::connectrpc::Dispatcher for ServerReflectionServer fn lookup( &self, path: &str, - ) -> Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { + ) -> ::std::option::Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { let method = path.strip_prefix("grpc.reflection.v1.ServerReflection/")?; match method { "ServerReflectionInfo" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::bidi_streaming() .with_spec(SERVER_REFLECTION_SERVER_REFLECTION_INFO_SPEC), ) } - _ => None, + _ => ::std::option::Option::None, } } fn call_unary( @@ -254,8 +254,8 @@ impl ::connectrpc::Dispatcher for ServerReflectionServer request: ::connectrpc::Payload, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path.strip_prefix("grpc.reflection.v1.ServerReflection/") - else { + let ::std::option::Option::Some(method) = path + .strip_prefix("grpc.reflection.v1.ServerReflection/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; let _ = (&ctx, &request, &format); @@ -270,8 +270,8 @@ impl ::connectrpc::Dispatcher for ServerReflectionServer request: ::buffa::bytes::Bytes, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path.strip_prefix("grpc.reflection.v1.ServerReflection/") - else { + let ::std::option::Option::Some(method) = path + .strip_prefix("grpc.reflection.v1.ServerReflection/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; let _ = (&ctx, &request, &format); @@ -286,8 +286,8 @@ impl ::connectrpc::Dispatcher for ServerReflectionServer requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path.strip_prefix("grpc.reflection.v1.ServerReflection/") - else { + let ::std::option::Option::Some(method) = path + .strip_prefix("grpc.reflection.v1.ServerReflection/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; let _ = (&ctx, &requests, &format); @@ -302,20 +302,20 @@ impl ::connectrpc::Dispatcher for ServerReflectionServer requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path.strip_prefix("grpc.reflection.v1.ServerReflection/") - else { + let ::std::option::Option::Some(method) = path + .strip_prefix("grpc.reflection.v1.ServerReflection/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; let _ = (&ctx, &requests, &format); match method { "ServerReflectionInfo" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let req_stream = ::connectrpc::dispatcher::codegen::decode_message_request_stream::< crate::proto::grpc::reflection::v1::ServerReflectionRequest, >(requests, format, ctx.decode_options().clone()); let resp = svc.server_reflection_info(ctx, req_stream).await?; - Ok( + ::std::result::Result::Ok( resp .map_body(|s| ::connectrpc::dispatcher::codegen::encode_response_stream::< crate::proto::grpc::reflection::v1::ServerReflectionResponse, @@ -400,8 +400,10 @@ pub struct ServerReflectionClient { impl ServerReflectionClient where T: ::connectrpc::client::ClientTransport, - ::Error: Into< - Box, + ::Error: ::std::convert::Into< + ::std::boxed::Box< + dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync, + >, >, { /// Create a new client with the given transport and configuration. @@ -419,7 +421,7 @@ where /// Call the ServerReflectionInfo RPC. Sends a request to /grpc.reflection.v1.ServerReflection/ServerReflectionInfo. pub async fn server_reflection_info( &self, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::BidiStream< T::ResponseBody, crate::proto::grpc::reflection::v1::ServerReflectionRequest, @@ -438,7 +440,7 @@ where pub async fn server_reflection_info_with_options( &self, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::BidiStream< T::ResponseBody, crate::proto::grpc::reflection::v1::ServerReflectionRequest, diff --git a/connectrpc-reflection/src/generated/connect/grpc.reflection.v1alpha.reflection.__connect.rs b/connectrpc-reflection/src/generated/connect/grpc.reflection.v1alpha.reflection.__connect.rs index 9a5e63a3..29f40461 100644 --- a/connectrpc-reflection/src/generated/connect/grpc.reflection.v1alpha.reflection.__connect.rs +++ b/connectrpc-reflection/src/generated/connect/grpc.reflection.v1alpha.reflection.__connect.rs @@ -110,7 +110,7 @@ pub const SERVER_REFLECTION_SERVER_REFLECTION_INFO_SPEC: ::connectrpc::Spec = :: /// [`PreEncoded`](::connectrpc::PreEncoded) — see its `# Streaming /// example` doc. #[allow(clippy::type_complexity)] -pub trait ServerReflection: Send + Sync + 'static { +pub trait ServerReflection: ::std::marker::Send + ::std::marker::Sync + 'static { /// The reflection service is structured as a bidirectional stream, ensuring /// all related requests go to a single server. /// @@ -129,10 +129,10 @@ pub trait ServerReflection: Send + Sync + 'static { ::connectrpc::ServiceStream< impl ::connectrpc::Encodable< crate::proto::grpc::reflection::v1alpha::ServerReflectionResponse, - > + Send + use, + > + ::std::marker::Send + use, >, >, - > + Send; + > + ::std::marker::Send; } /// Extension trait for registering a service implementation with a Router. /// @@ -225,7 +225,7 @@ impl ServerReflectionServer { Self { inner } } } -impl Clone for ServerReflectionServer { +impl ::std::clone::Clone for ServerReflectionServer { fn clone(&self) -> Self { Self { inner: ::std::sync::Arc::clone(&self.inner), @@ -237,16 +237,16 @@ impl ::connectrpc::Dispatcher for ServerReflectionServer fn lookup( &self, path: &str, - ) -> Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { + ) -> ::std::option::Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { let method = path.strip_prefix("grpc.reflection.v1alpha.ServerReflection/")?; match method { "ServerReflectionInfo" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::bidi_streaming() .with_spec(SERVER_REFLECTION_SERVER_REFLECTION_INFO_SPEC), ) } - _ => None, + _ => ::std::option::Option::None, } } fn call_unary( @@ -256,8 +256,8 @@ impl ::connectrpc::Dispatcher for ServerReflectionServer request: ::connectrpc::Payload, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path.strip_prefix("grpc.reflection.v1alpha.ServerReflection/") - else { + let ::std::option::Option::Some(method) = path + .strip_prefix("grpc.reflection.v1alpha.ServerReflection/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; let _ = (&ctx, &request, &format); @@ -272,8 +272,8 @@ impl ::connectrpc::Dispatcher for ServerReflectionServer request: ::buffa::bytes::Bytes, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path.strip_prefix("grpc.reflection.v1alpha.ServerReflection/") - else { + let ::std::option::Option::Some(method) = path + .strip_prefix("grpc.reflection.v1alpha.ServerReflection/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; let _ = (&ctx, &request, &format); @@ -288,8 +288,8 @@ impl ::connectrpc::Dispatcher for ServerReflectionServer requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path.strip_prefix("grpc.reflection.v1alpha.ServerReflection/") - else { + let ::std::option::Option::Some(method) = path + .strip_prefix("grpc.reflection.v1alpha.ServerReflection/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; let _ = (&ctx, &requests, &format); @@ -304,20 +304,20 @@ impl ::connectrpc::Dispatcher for ServerReflectionServer requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path.strip_prefix("grpc.reflection.v1alpha.ServerReflection/") - else { + let ::std::option::Option::Some(method) = path + .strip_prefix("grpc.reflection.v1alpha.ServerReflection/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; let _ = (&ctx, &requests, &format); match method { "ServerReflectionInfo" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let req_stream = ::connectrpc::dispatcher::codegen::decode_message_request_stream::< crate::proto::grpc::reflection::v1alpha::ServerReflectionRequest, >(requests, format, ctx.decode_options().clone()); let resp = svc.server_reflection_info(ctx, req_stream).await?; - Ok( + ::std::result::Result::Ok( resp .map_body(|s| ::connectrpc::dispatcher::codegen::encode_response_stream::< crate::proto::grpc::reflection::v1alpha::ServerReflectionResponse, @@ -402,8 +402,10 @@ pub struct ServerReflectionClient { impl ServerReflectionClient where T: ::connectrpc::client::ClientTransport, - ::Error: Into< - Box, + ::Error: ::std::convert::Into< + ::std::boxed::Box< + dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync, + >, >, { /// Create a new client with the given transport and configuration. @@ -421,7 +423,7 @@ where /// Call the ServerReflectionInfo RPC. Sends a request to /grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo. pub async fn server_reflection_info( &self, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::BidiStream< T::ResponseBody, crate::proto::grpc::reflection::v1alpha::ServerReflectionRequest, @@ -440,7 +442,7 @@ where pub async fn server_reflection_info_with_options( &self, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::BidiStream< T::ResponseBody, crate::proto::grpc::reflection::v1alpha::ServerReflectionRequest, diff --git a/docs/guide.md b/docs/guide.md index 4d8cbb47..377a1f69 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -405,11 +405,27 @@ becomes an async method. Every service in a proto package is generated into one Rust module, so the names derived from them must be distinct after that normalization: -two services that differ only in case or underscores (`XGet` and +two services whose names become the same UpperCamelCase name (`XGet` and `X_Get`), or a service and method pair whose words split differently from another's (`XGet.Foo` and `X.GetFoo` both name the `X_GET_FOO_SPEC` constant), are rejected at generation time with a -message naming both sides. Rename one of them in the proto. +message naming both sides. Rename one of them in the proto. The check +covers services only: a message or enum named like one of a service's +generated items (`GreetServiceClient`, `GreetServiceServer`, +`GreetServiceExt`) is accepted. In `connectrpc-build` output, where messages +share that module, the generated code then fails to compile with E0428. + +The generated code compiles when a message, enum or service has the name of +a standard library type or trait, such as `message Result` or +`service Send`. A glob import of that package, like +`use proto::greet::v1::*;` in the [quick start](#quick-start), shadows the +standard name in your module, in server and client code alike. After +`use proto::arrow::flight::protocol::*;`, `Result` means the message, +and the compiler reports E0107 (wrong number of generic arguments) on your +own code. Import the module under a short name instead, with +`use proto::arrow::flight::protocol as flight;`, and write `flight::Result`. +With `buf generate`, the service items are in the `connect` tree, so import +that module the same way. ### Handler signatures diff --git a/examples/eliza/src/generated/connect/connectrpc.eliza.v1.eliza.__connect.rs b/examples/eliza/src/generated/connect/connectrpc.eliza.v1.eliza.__connect.rs index 3e61eb55..4c966cfb 100644 --- a/examples/eliza/src/generated/connect/connectrpc.eliza.v1.eliza.__connect.rs +++ b/examples/eliza/src/generated/connect/connectrpc.eliza.v1.eliza.__connect.rs @@ -199,7 +199,7 @@ pub const ELIZA_SERVICE_INTRODUCE_SPEC: ::connectrpc::Spec = ::connectrpc::Spec: /// [`PreEncoded`](::connectrpc::PreEncoded) — see its `# Streaming /// example` doc. #[allow(clippy::type_complexity)] -pub trait ElizaService: Send + Sync + 'static { +pub trait ElizaService: ::std::marker::Send + ::std::marker::Sync + 'static { /// Say is a unary RPC. Eliza responds to the prompt with a single sentence. /// /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). @@ -220,9 +220,9 @@ pub trait ElizaService: Send + Sync + 'static { Output = ::connectrpc::ServiceResult< impl ::connectrpc::Encodable< crate::proto::connectrpc::eliza::v1::SayResponse, - > + Send + use<'a, Self>, + > + ::std::marker::Send + use<'a, Self>, >, - > + Send; + > + ::std::marker::Send; /// Converse is a bidirectional RPC. The caller may exchange multiple /// back-and-forth messages with Eliza over a long-lived connection. Eliza /// responds to each ConverseRequest with a ConverseResponse. @@ -242,10 +242,10 @@ pub trait ElizaService: Send + Sync + 'static { ::connectrpc::ServiceStream< impl ::connectrpc::Encodable< crate::proto::connectrpc::eliza::v1::ConverseResponse, - > + Send + use, + > + ::std::marker::Send + use, >, >, - > + Send; + > + ::std::marker::Send; /// Introduce is a server streaming RPC. Given the caller's name, Eliza /// returns a stream of sentences to introduce itself. /// @@ -266,10 +266,10 @@ pub trait ElizaService: Send + Sync + 'static { ::connectrpc::ServiceStream< impl ::connectrpc::Encodable< crate::proto::connectrpc::eliza::v1::IntroduceResponse, - > + Send + use, + > + ::std::marker::Send + use, >, >, - > + Send; + > + ::std::marker::Send; } /// Extension trait for registering a service implementation with a Router. /// @@ -419,7 +419,7 @@ impl ElizaServiceServer { Self { inner } } } -impl Clone for ElizaServiceServer { +impl ::std::clone::Clone for ElizaServiceServer { fn clone(&self) -> Self { Self { inner: ::std::sync::Arc::clone(&self.inner), @@ -431,28 +431,28 @@ impl ::connectrpc::Dispatcher for ElizaServiceServer { fn lookup( &self, path: &str, - ) -> Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { + ) -> ::std::option::Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { let method = path.strip_prefix("connectrpc.eliza.v1.ElizaService/")?; match method { "Say" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(true) .with_spec(ELIZA_SERVICE_SAY_SPEC), ) } "Converse" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::bidi_streaming() .with_spec(ELIZA_SERVICE_CONVERSE_SPEC), ) } "Introduce" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::server_streaming() .with_spec(ELIZA_SERVICE_INTRODUCE_SPEC), ) } - _ => None, + _ => ::std::option::Option::None, } } fn call_unary( @@ -462,14 +462,15 @@ impl ::connectrpc::Dispatcher for ElizaServiceServer { request: ::connectrpc::Payload, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path.strip_prefix("connectrpc.eliza.v1.ElizaService/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("connectrpc.eliza.v1.ElizaService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; let _ = (&ctx, &request, &format); match method { "Say" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let body = ::connectrpc::dispatcher::codegen::request_proto_bytes::< crate::proto::connectrpc::eliza::v1::SayRequest, >(request.encoded()?, format)?; @@ -499,14 +500,15 @@ impl ::connectrpc::Dispatcher for ElizaServiceServer { request: ::buffa::bytes::Bytes, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path.strip_prefix("connectrpc.eliza.v1.ElizaService/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("connectrpc.eliza.v1.ElizaService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; let _ = (&ctx, &request, &format); match method { "Introduce" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let body = ::connectrpc::dispatcher::codegen::request_proto_bytes::< crate::proto::connectrpc::eliza::v1::IntroduceRequest, >(request, format)?; @@ -520,7 +522,7 @@ impl ::connectrpc::Dispatcher for ElizaServiceServer { crate::proto::connectrpc::eliza::v1::IntroduceRequest, >::from_parts(&req, &body); let resp = svc.introduce(ctx, req).await?; - Ok( + ::std::result::Result::Ok( resp .map_body(|s| ::connectrpc::dispatcher::codegen::encode_response_stream::< crate::proto::connectrpc::eliza::v1::IntroduceResponse, @@ -540,7 +542,8 @@ impl ::connectrpc::Dispatcher for ElizaServiceServer { requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path.strip_prefix("connectrpc.eliza.v1.ElizaService/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("connectrpc.eliza.v1.ElizaService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; let _ = (&ctx, &requests, &format); @@ -555,19 +558,20 @@ impl ::connectrpc::Dispatcher for ElizaServiceServer { requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path.strip_prefix("connectrpc.eliza.v1.ElizaService/") else { + let ::std::option::Option::Some(method) = path + .strip_prefix("connectrpc.eliza.v1.ElizaService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; let _ = (&ctx, &requests, &format); match method { "Converse" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let req_stream = ::connectrpc::dispatcher::codegen::decode_message_request_stream::< crate::proto::connectrpc::eliza::v1::ConverseRequest, >(requests, format, ctx.decode_options().clone()); let resp = svc.converse(ctx, req_stream).await?; - Ok( + ::std::result::Result::Ok( resp .map_body(|s| ::connectrpc::dispatcher::codegen::encode_response_stream::< crate::proto::connectrpc::eliza::v1::ConverseResponse, @@ -650,8 +654,10 @@ pub struct ElizaServiceClient { impl ElizaServiceClient where T: ::connectrpc::client::ClientTransport, - ::Error: Into< - Box, + ::Error: ::std::convert::Into< + ::std::boxed::Box< + dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync, + >, >, { /// Create a new client with the given transport and configuration. @@ -670,7 +676,7 @@ where pub async fn say( &self, request: crate::proto::connectrpc::eliza::v1::SayRequest, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::connectrpc::eliza::v1::__buffa::view::SayResponseView< @@ -688,7 +694,7 @@ where &self, request: crate::proto::connectrpc::eliza::v1::SayRequest, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::connectrpc::eliza::v1::__buffa::view::SayResponseView< @@ -710,7 +716,7 @@ where /// Call the Converse RPC. Sends a request to /connectrpc.eliza.v1.ElizaService/Converse. pub async fn converse( &self, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::BidiStream< T::ResponseBody, crate::proto::connectrpc::eliza::v1::ConverseRequest, @@ -726,7 +732,7 @@ where pub async fn converse_with_options( &self, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::BidiStream< T::ResponseBody, crate::proto::connectrpc::eliza::v1::ConverseRequest, @@ -749,7 +755,7 @@ where pub async fn introduce( &self, request: crate::proto::connectrpc::eliza::v1::IntroduceRequest, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::ServerStream< T::ResponseBody, crate::proto::connectrpc::eliza::v1::__buffa::view::IntroduceResponseView< @@ -769,7 +775,7 @@ where &self, request: crate::proto::connectrpc::eliza::v1::IntroduceRequest, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::ServerStream< T::ResponseBody, crate::proto::connectrpc::eliza::v1::__buffa::view::IntroduceResponseView< diff --git a/examples/multiservice/src/generated/connect/anthropic.connectrpc.greet.v1.greet.__connect.rs b/examples/multiservice/src/generated/connect/anthropic.connectrpc.greet.v1.greet.__connect.rs index 98b6a99b..15cf5513 100644 --- a/examples/multiservice/src/generated/connect/anthropic.connectrpc.greet.v1.greet.__connect.rs +++ b/examples/multiservice/src/generated/connect/anthropic.connectrpc.greet.v1.greet.__connect.rs @@ -110,7 +110,7 @@ pub const GREET_SERVICE_GREET_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::ser /// [`PreEncoded`](::connectrpc::PreEncoded) — see its `# Streaming /// example` doc. #[allow(clippy::type_complexity)] -pub trait GreetService: Send + Sync + 'static { +pub trait GreetService: ::std::marker::Send + ::std::marker::Sync + 'static { /// Greet returns a greeting message for the given name. /// This method has no side effects and supports GET requests. /// @@ -132,9 +132,9 @@ pub trait GreetService: Send + Sync + 'static { Output = ::connectrpc::ServiceResult< impl ::connectrpc::Encodable< crate::proto::anthropic::connectrpc::greet::v1::GreetResponse, - > + Send + use<'a, Self>, + > + ::std::marker::Send + use<'a, Self>, >, - > + Send; + > + ::std::marker::Send; } /// Extension trait for registering a service implementation with a Router. /// @@ -235,7 +235,7 @@ impl GreetServiceServer { Self { inner } } } -impl Clone for GreetServiceServer { +impl ::std::clone::Clone for GreetServiceServer { fn clone(&self) -> Self { Self { inner: ::std::sync::Arc::clone(&self.inner), @@ -247,16 +247,16 @@ impl ::connectrpc::Dispatcher for GreetServiceServer { fn lookup( &self, path: &str, - ) -> Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { + ) -> ::std::option::Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { let method = path.strip_prefix("anthropic.connectrpc.greet.v1.GreetService/")?; match method { "Greet" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(true) .with_spec(GREET_SERVICE_GREET_SPEC), ) } - _ => None, + _ => ::std::option::Option::None, } } fn call_unary( @@ -266,7 +266,7 @@ impl ::connectrpc::Dispatcher for GreetServiceServer { request: ::connectrpc::Payload, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path + let ::std::option::Option::Some(method) = path .strip_prefix("anthropic.connectrpc.greet.v1.GreetService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; @@ -274,7 +274,7 @@ impl ::connectrpc::Dispatcher for GreetServiceServer { match method { "Greet" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let body = ::connectrpc::dispatcher::codegen::request_proto_bytes::< crate::proto::anthropic::connectrpc::greet::v1::GreetRequest, >(request.encoded()?, format)?; @@ -304,7 +304,7 @@ impl ::connectrpc::Dispatcher for GreetServiceServer { request: ::buffa::bytes::Bytes, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path + let ::std::option::Option::Some(method) = path .strip_prefix("anthropic.connectrpc.greet.v1.GreetService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; @@ -320,7 +320,7 @@ impl ::connectrpc::Dispatcher for GreetServiceServer { requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path + let ::std::option::Option::Some(method) = path .strip_prefix("anthropic.connectrpc.greet.v1.GreetService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; @@ -336,7 +336,7 @@ impl ::connectrpc::Dispatcher for GreetServiceServer { requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path + let ::std::option::Option::Some(method) = path .strip_prefix("anthropic.connectrpc.greet.v1.GreetService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; @@ -415,8 +415,10 @@ pub struct GreetServiceClient { impl GreetServiceClient where T: ::connectrpc::client::ClientTransport, - ::Error: Into< - Box, + ::Error: ::std::convert::Into< + ::std::boxed::Box< + dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync, + >, >, { /// Create a new client with the given transport and configuration. @@ -435,7 +437,7 @@ where pub async fn greet( &self, request: crate::proto::anthropic::connectrpc::greet::v1::GreetRequest, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::anthropic::connectrpc::greet::v1::__buffa::view::GreetResponseView< @@ -453,7 +455,7 @@ where &self, request: crate::proto::anthropic::connectrpc::greet::v1::GreetRequest, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::anthropic::connectrpc::greet::v1::__buffa::view::GreetResponseView< diff --git a/examples/multiservice/src/generated/connect/anthropic.connectrpc.math.v1.math.__connect.rs b/examples/multiservice/src/generated/connect/anthropic.connectrpc.math.v1.math.__connect.rs index ed495904..1f562f02 100644 --- a/examples/multiservice/src/generated/connect/anthropic.connectrpc.math.v1.math.__connect.rs +++ b/examples/multiservice/src/generated/connect/anthropic.connectrpc.math.v1.math.__connect.rs @@ -102,7 +102,7 @@ pub const MATH_SERVICE_ADD_SPEC: ::connectrpc::Spec = ::connectrpc::Spec::server /// [`PreEncoded`](::connectrpc::PreEncoded) — see its `# Streaming /// example` doc. #[allow(clippy::type_complexity)] -pub trait MathService: Send + Sync + 'static { +pub trait MathService: ::std::marker::Send + ::std::marker::Sync + 'static { /// Add returns the sum of two numbers. /// /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). @@ -123,9 +123,9 @@ pub trait MathService: Send + Sync + 'static { Output = ::connectrpc::ServiceResult< impl ::connectrpc::Encodable< crate::proto::anthropic::connectrpc::math::v1::AddResponse, - > + Send + use<'a, Self>, + > + ::std::marker::Send + use<'a, Self>, >, - > + Send; + > + ::std::marker::Send; } /// Extension trait for registering a service implementation with a Router. /// @@ -226,7 +226,7 @@ impl MathServiceServer { Self { inner } } } -impl Clone for MathServiceServer { +impl ::std::clone::Clone for MathServiceServer { fn clone(&self) -> Self { Self { inner: ::std::sync::Arc::clone(&self.inner), @@ -238,16 +238,16 @@ impl ::connectrpc::Dispatcher for MathServiceServer { fn lookup( &self, path: &str, - ) -> Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { + ) -> ::std::option::Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { let method = path.strip_prefix("anthropic.connectrpc.math.v1.MathService/")?; match method { "Add" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) .with_spec(MATH_SERVICE_ADD_SPEC), ) } - _ => None, + _ => ::std::option::Option::None, } } fn call_unary( @@ -257,15 +257,15 @@ impl ::connectrpc::Dispatcher for MathServiceServer { request: ::connectrpc::Payload, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path.strip_prefix("anthropic.connectrpc.math.v1.MathService/") - else { + let ::std::option::Option::Some(method) = path + .strip_prefix("anthropic.connectrpc.math.v1.MathService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; let _ = (&ctx, &request, &format); match method { "Add" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let body = ::connectrpc::dispatcher::codegen::request_proto_bytes::< crate::proto::anthropic::connectrpc::math::v1::AddRequest, >(request.encoded()?, format)?; @@ -295,8 +295,8 @@ impl ::connectrpc::Dispatcher for MathServiceServer { request: ::buffa::bytes::Bytes, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path.strip_prefix("anthropic.connectrpc.math.v1.MathService/") - else { + let ::std::option::Option::Some(method) = path + .strip_prefix("anthropic.connectrpc.math.v1.MathService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; let _ = (&ctx, &request, &format); @@ -311,8 +311,8 @@ impl ::connectrpc::Dispatcher for MathServiceServer { requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path.strip_prefix("anthropic.connectrpc.math.v1.MathService/") - else { + let ::std::option::Option::Some(method) = path + .strip_prefix("anthropic.connectrpc.math.v1.MathService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; let _ = (&ctx, &requests, &format); @@ -327,8 +327,8 @@ impl ::connectrpc::Dispatcher for MathServiceServer { requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path.strip_prefix("anthropic.connectrpc.math.v1.MathService/") - else { + let ::std::option::Option::Some(method) = path + .strip_prefix("anthropic.connectrpc.math.v1.MathService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; let _ = (&ctx, &requests, &format); @@ -406,8 +406,10 @@ pub struct MathServiceClient { impl MathServiceClient where T: ::connectrpc::client::ClientTransport, - ::Error: Into< - Box, + ::Error: ::std::convert::Into< + ::std::boxed::Box< + dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync, + >, >, { /// Create a new client with the given transport and configuration. @@ -426,7 +428,7 @@ where pub async fn add( &self, request: crate::proto::anthropic::connectrpc::math::v1::AddRequest, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::anthropic::connectrpc::math::v1::__buffa::view::AddResponseView< @@ -444,7 +446,7 @@ where &self, request: crate::proto::anthropic::connectrpc::math::v1::AddRequest, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::anthropic::connectrpc::math::v1::__buffa::view::AddResponseView< diff --git a/examples/multiservice/src/generated/connect/anthropic.connectrpc.wkt.v1.wkt.__connect.rs b/examples/multiservice/src/generated/connect/anthropic.connectrpc.wkt.v1.wkt.__connect.rs index ee582445..6639443f 100644 --- a/examples/multiservice/src/generated/connect/anthropic.connectrpc.wkt.v1.wkt.__connect.rs +++ b/examples/multiservice/src/generated/connect/anthropic.connectrpc.wkt.v1.wkt.__connect.rs @@ -244,7 +244,7 @@ pub const WELL_KNOWN_TYPES_SERVICE_HEARTBEAT_SPEC: ::connectrpc::Spec = ::connec /// [`PreEncoded`](::connectrpc::PreEncoded) — see its `# Streaming /// example` doc. #[allow(clippy::type_complexity)] -pub trait WellKnownTypesService: Send + Sync + 'static { +pub trait WellKnownTypesService: ::std::marker::Send + ::std::marker::Sync + 'static { /// CreateEvent creates an event with a timestamp. /// /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). @@ -265,9 +265,9 @@ pub trait WellKnownTypesService: Send + Sync + 'static { Output = ::connectrpc::ServiceResult< impl ::connectrpc::Encodable< crate::proto::anthropic::connectrpc::wkt::v1::CreateEventResponse, - > + Send + use<'a, Self>, + > + ::std::marker::Send + use<'a, Self>, >, - > + Send; + > + ::std::marker::Send; /// CalculateDuration calculates the duration between two timestamps. /// /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). @@ -288,9 +288,9 @@ pub trait WellKnownTypesService: Send + Sync + 'static { Output = ::connectrpc::ServiceResult< impl ::connectrpc::Encodable< crate::proto::anthropic::connectrpc::wkt::v1::CalculateDurationResponse, - > + Send + use<'a, Self>, + > + ::std::marker::Send + use<'a, Self>, >, - > + Send; + > + ::std::marker::Send; /// ProcessMetadata processes arbitrary metadata as a Struct. /// /// `'a` lets the response body borrow from `&self` (e.g. server-resident state). @@ -311,9 +311,9 @@ pub trait WellKnownTypesService: Send + Sync + 'static { Output = ::connectrpc::ServiceResult< impl ::connectrpc::Encodable< crate::proto::anthropic::connectrpc::wkt::v1::ProcessMetadataResponse, - > + Send + use<'a, Self>, + > + ::std::marker::Send + use<'a, Self>, >, - > + Send; + > + ::std::marker::Send; /// Heartbeat returns the server's current time. Exercises well-known /// types as the direct RPC input (Empty) and output (Timestamp). /// @@ -332,9 +332,9 @@ pub trait WellKnownTypesService: Send + Sync + 'static { Output = ::connectrpc::ServiceResult< impl ::connectrpc::Encodable< ::buffa_types::google::protobuf::Timestamp, - > + Send + use<'a, Self>, + > + ::std::marker::Send + use<'a, Self>, >, - > + Send; + > + ::std::marker::Send; } /// Extension trait for registering a service implementation with a Router. /// @@ -524,7 +524,7 @@ impl WellKnownTypesServiceServer { Self { inner } } } -impl Clone for WellKnownTypesServiceServer { +impl ::std::clone::Clone for WellKnownTypesServiceServer { fn clone(&self) -> Self { Self { inner: ::std::sync::Arc::clone(&self.inner), @@ -537,35 +537,35 @@ for WellKnownTypesServiceServer { fn lookup( &self, path: &str, - ) -> Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { + ) -> ::std::option::Option<::connectrpc::dispatcher::codegen::MethodDescriptor> { let method = path .strip_prefix("anthropic.connectrpc.wkt.v1.WellKnownTypesService/")?; match method { "CreateEvent" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) .with_spec(WELL_KNOWN_TYPES_SERVICE_CREATE_EVENT_SPEC), ) } "CalculateDuration" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) .with_spec(WELL_KNOWN_TYPES_SERVICE_CALCULATE_DURATION_SPEC), ) } "ProcessMetadata" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) .with_spec(WELL_KNOWN_TYPES_SERVICE_PROCESS_METADATA_SPEC), ) } "Heartbeat" => { - Some( + ::std::option::Option::Some( ::connectrpc::dispatcher::codegen::MethodDescriptor::unary(false) .with_spec(WELL_KNOWN_TYPES_SERVICE_HEARTBEAT_SPEC), ) } - _ => None, + _ => ::std::option::Option::None, } } fn call_unary( @@ -575,7 +575,7 @@ for WellKnownTypesServiceServer { request: ::connectrpc::Payload, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path + let ::std::option::Option::Some(method) = path .strip_prefix("anthropic.connectrpc.wkt.v1.WellKnownTypesService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; @@ -583,7 +583,7 @@ for WellKnownTypesServiceServer { match method { "CreateEvent" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let body = ::connectrpc::dispatcher::codegen::request_proto_bytes::< crate::proto::anthropic::connectrpc::wkt::v1::CreateEventRequest, >(request.encoded()?, format)?; @@ -605,7 +605,7 @@ for WellKnownTypesServiceServer { } "CalculateDuration" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let body = ::connectrpc::dispatcher::codegen::request_proto_bytes::< crate::proto::anthropic::connectrpc::wkt::v1::CalculateDurationRequest, >(request.encoded()?, format)?; @@ -627,7 +627,7 @@ for WellKnownTypesServiceServer { } "ProcessMetadata" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let body = ::connectrpc::dispatcher::codegen::request_proto_bytes::< crate::proto::anthropic::connectrpc::wkt::v1::ProcessMetadataRequest, >(request.encoded()?, format)?; @@ -649,7 +649,7 @@ for WellKnownTypesServiceServer { } "Heartbeat" => { let svc = ::std::sync::Arc::clone(&self.inner); - Box::pin(async move { + ::std::boxed::Box::pin(async move { let body = ::connectrpc::dispatcher::codegen::request_proto_bytes::< ::buffa_types::google::protobuf::Empty, >(request.encoded()?, format)?; @@ -677,7 +677,7 @@ for WellKnownTypesServiceServer { request: ::buffa::bytes::Bytes, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path + let ::std::option::Option::Some(method) = path .strip_prefix("anthropic.connectrpc.wkt.v1.WellKnownTypesService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; @@ -693,7 +693,7 @@ for WellKnownTypesServiceServer { requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::UnaryResult { - let Some(method) = path + let ::std::option::Option::Some(method) = path .strip_prefix("anthropic.connectrpc.wkt.v1.WellKnownTypesService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_unary(path); }; @@ -709,7 +709,7 @@ for WellKnownTypesServiceServer { requests: ::connectrpc::dispatcher::codegen::RequestStream, format: ::connectrpc::CodecFormat, ) -> ::connectrpc::dispatcher::codegen::StreamingResult { - let Some(method) = path + let ::std::option::Option::Some(method) = path .strip_prefix("anthropic.connectrpc.wkt.v1.WellKnownTypesService/") else { return ::connectrpc::dispatcher::codegen::unimplemented_streaming(path); }; @@ -788,8 +788,10 @@ pub struct WellKnownTypesServiceClient { impl WellKnownTypesServiceClient where T: ::connectrpc::client::ClientTransport, - ::Error: Into< - Box, + ::Error: ::std::convert::Into< + ::std::boxed::Box< + dyn ::std::error::Error + ::std::marker::Send + ::std::marker::Sync, + >, >, { /// Create a new client with the given transport and configuration. @@ -808,7 +810,7 @@ where pub async fn create_event( &self, request: crate::proto::anthropic::connectrpc::wkt::v1::CreateEventRequest, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::anthropic::connectrpc::wkt::v1::__buffa::view::CreateEventResponseView< @@ -829,7 +831,7 @@ where &self, request: crate::proto::anthropic::connectrpc::wkt::v1::CreateEventRequest, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::anthropic::connectrpc::wkt::v1::__buffa::view::CreateEventResponseView< @@ -853,7 +855,7 @@ where pub async fn calculate_duration( &self, request: crate::proto::anthropic::connectrpc::wkt::v1::CalculateDurationRequest, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::anthropic::connectrpc::wkt::v1::__buffa::view::CalculateDurationResponseView< @@ -874,7 +876,7 @@ where &self, request: crate::proto::anthropic::connectrpc::wkt::v1::CalculateDurationRequest, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::anthropic::connectrpc::wkt::v1::__buffa::view::CalculateDurationResponseView< @@ -898,7 +900,7 @@ where pub async fn process_metadata( &self, request: crate::proto::anthropic::connectrpc::wkt::v1::ProcessMetadataRequest, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::anthropic::connectrpc::wkt::v1::__buffa::view::ProcessMetadataResponseView< @@ -919,7 +921,7 @@ where &self, request: crate::proto::anthropic::connectrpc::wkt::v1::ProcessMetadataRequest, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< crate::proto::anthropic::connectrpc::wkt::v1::__buffa::view::ProcessMetadataResponseView< @@ -943,7 +945,7 @@ where pub async fn heartbeat( &self, request: ::buffa_types::google::protobuf::Empty, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< ::buffa_types::google::protobuf::__buffa::view::TimestampView<'static>, @@ -962,7 +964,7 @@ where &self, request: ::buffa_types::google::protobuf::Empty, options: ::connectrpc::client::CallOptions, - ) -> Result< + ) -> ::std::result::Result< ::connectrpc::client::UnaryResponse< ::buffa::view::OwnedView< ::buffa_types::google::protobuf::__buffa::view::TimestampView<'static>, diff --git a/tests/streaming/build.rs b/tests/streaming/build.rs index 40cb28dd..d8cbf931 100644 --- a/tests/streaming/build.rs +++ b/tests/streaming/build.rs @@ -1,6 +1,11 @@ fn main() { connectrpc_build::Config::new() - .files(&["proto/echo.proto"]) + .files(&[ + "proto/echo.proto", + "proto/shadow_child.proto", + "proto/shadow_services.proto", + "proto/shadow_types.proto", + ]) .includes(&["proto/"]) .include_file("_connectrpc.rs") .compile() diff --git a/tests/streaming/proto/shadow_child.proto b/tests/streaming/proto/shadow_child.proto new file mode 100644 index 00000000..a555af0d --- /dev/null +++ b/tests/streaming/proto/shadow_child.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; + +package test.shadow.types.v1.child; + +// A sub-package of the package in `shadow_types.proto`. Its Rust module +// glob-imports its parent, so every name declared there is in scope here too. +service ChildService { + rpc Unary(ChildRequest) returns (ChildResponse); + rpc ServerStream(ChildRequest) returns (stream ChildResponse); + rpc ClientStream(stream ChildRequest) returns (ChildResponse); + rpc Bidi(stream ChildRequest) returns (stream ChildResponse); +} + +message ChildRequest {} + +message ChildResponse {} diff --git a/tests/streaming/proto/shadow_services.proto b/tests/streaming/proto/shadow_services.proto new file mode 100644 index 00000000..44841383 --- /dev/null +++ b/tests/streaming/proto/shadow_services.proto @@ -0,0 +1,51 @@ +syntax = "proto3"; + +package test.shadow.services.v1; + +// Services named after what the generated service code refers to: prelude +// items, and the generic parameters `S` and `T` of the generated `impl` +// blocks. Each service's trait takes the service's name. `Result` has an RPC +// of each of the four types, so that the module holds all of the generated code. + +service Result { + rpc Unary(Request) returns (Response); + rpc ServerStream(Request) returns (stream Response); + rpc ClientStream(stream Request) returns (Response); + rpc Bidi(stream Request) returns (stream Response); +} + +service Box { + rpc Call(Request) returns (Response); +} + +service Clone { + rpc Call(Request) returns (Response); +} + +service Into { + rpc Call(Request) returns (Response); +} + +service Option { + rpc Call(Request) returns (Response); +} + +service S { + rpc Call(Request) returns (Response); +} + +service Send { + rpc Call(Request) returns (Response); +} + +service Sync { + rpc Call(Request) returns (Response); +} + +service T { + rpc Call(Request) returns (Response); +} + +message Request {} + +message Response {} diff --git a/tests/streaming/proto/shadow_types.proto b/tests/streaming/proto/shadow_types.proto new file mode 100644 index 00000000..1e00e583 --- /dev/null +++ b/tests/streaming/proto/shadow_types.proto @@ -0,0 +1,92 @@ +syntax = "proto3"; + +package test.shadow.types.v1; + +// Messages and enums named after what the generated service code refers to. + +// RPC types named after the generic parameters of the generated `impl` blocks. +service GenericParamService { + rpc Unary(S) returns (T); + rpc ServerStream(T) returns (stream S); + rpc ClientStream(stream S) returns (T); + rpc Bidi(stream T) returns (stream S); +} + +message S { + string value = 1; +} + +message T { + string value = 1; +} + +// RPC types named after prelude items. +service PreludeService { + rpc Unary(Option) returns (Result); + rpc ServerStream(Box) returns (stream Send); + rpc ClientStream(stream Sync) returns (Clone); + rpc Bidi(stream Into) returns (stream From); +} + +message Option { + string value = 1; +} + +message Result { + string value = 1; +} + +message Box {} +message Send {} +message Sync {} +message Clone {} +message Into {} +message From {} + +// The rest of the Rust 2024 prelude's types and traits, and the names of the +// variants of `Option` and `Result`. A message is a type and not a value, so +// `message Some` leaves the `Some(…)` constructor alone. +message AsMut {} +message AsRef {} +message AsyncFn {} +message AsyncFnMut {} +message AsyncFnOnce {} +message Copy {} +message Default {} +message DoubleEndedIterator {} +message Drop {} +message Eq {} +message Err {} +message ExactSizeIterator {} +message Extend {} +message Fn {} +message FnMut {} +message FnOnce {} +message FromIterator {} +message Future {} +message IntoFuture {} +message IntoIterator {} +message Iterator {} +message None {} +message Ok {} +message Ord {} +message PartialEq {} +message PartialOrd {} +message Sized {} +message Some {} +message String {} +message ToOwned {} +message ToString {} +message TryFrom {} +message TryInto {} +message Unpin {} +message Vec {} + +// Standard items outside the prelude that the service code names. +enum Arc { + ARC_UNSPECIFIED = 0; +} + +enum Error { + ERROR_UNSPECIFIED = 0; +} diff --git a/tests/streaming/src/lib.rs b/tests/streaming/src/lib.rs index bef6ff35..778537b4 100644 --- a/tests/streaming/src/lib.rs +++ b/tests/streaming/src/lib.rs @@ -3,6 +3,9 @@ pub mod proto { } pub use proto::test::echo::v1::*; +#[cfg(test)] +mod shadow; + #[cfg(test)] mod tests { diff --git a/tests/streaming/src/shadow.rs b/tests/streaming/src/shadow.rs new file mode 100644 index 00000000..1a1d97f7 --- /dev/null +++ b/tests/streaming/src/shadow.rs @@ -0,0 +1,218 @@ +//! Proto types and services named after what generated service code refers +//! to: prelude items such as `Result` and `Send`, and the generic parameters +//! `S` and `T`. +//! +//! That the generated code for the `shadow_*.proto` files compiles is the main +//! assertion; for `services::Result` and `ChildService` it is the only one. +//! The other service traits are implemented, and the calls with `S` and `T` +//! run each type of RPC through the Router and the dispatcher. + +use std::sync::Arc; + +use connectrpc::client::{ClientConfig, HttpClient}; +use connectrpc::{ + ConnectError, ConnectRpcService, InboundStream, RequestContext, Response, Router, + ServiceRequest, ServiceResult, ServiceStream, +}; +use futures::StreamExt; +use tokio::net::TcpListener; + +use crate::proto::test::shadow::{services::v1 as services, types::v1 as types}; + +fn s(value: String) -> types::S { + types::S { + value, + ..Default::default() + } +} + +fn t(value: String) -> types::T { + types::T { + value, + ..Default::default() + } +} + +struct Impl; + +impl types::GenericParamService for Impl { + async fn unary( + &self, + _ctx: RequestContext, + request: ServiceRequest<'_, types::S>, + ) -> ServiceResult { + Response::ok(t(format!("unary {}", request.value))) + } + + async fn server_stream( + &self, + _ctx: RequestContext, + request: ServiceRequest<'_, types::T>, + ) -> ServiceResult> { + let item = s(format!("server_stream {}", request.value)); + Response::stream_ok(futures::stream::iter([Ok::<_, ConnectError>(item)])) + } + + async fn client_stream( + &self, + _ctx: RequestContext, + mut requests: InboundStream, + ) -> ServiceResult { + let mut values = vec!["client_stream".to_owned()]; + while let Some(request) = requests.next().await { + values.push(request?.view().value.to_owned()); + } + Response::ok(t(values.join(" "))) + } + + async fn bidi( + &self, + _ctx: RequestContext, + requests: InboundStream, + ) -> ServiceResult> { + Response::stream_ok( + requests.map(|request| Ok(s(format!("bidi {}", request?.view().value)))), + ) + } +} + +impl types::PreludeService for Impl { + async fn unary( + &self, + _ctx: RequestContext, + request: ServiceRequest<'_, types::Option>, + ) -> ServiceResult { + Response::ok(types::Result { + value: format!("unary {}", request.value), + ..Default::default() + }) + } + + async fn server_stream( + &self, + _ctx: RequestContext, + _request: ServiceRequest<'_, types::Box>, + ) -> ServiceResult> { + Response::stream_ok(futures::stream::empty()) + } + + async fn client_stream( + &self, + _ctx: RequestContext, + _requests: InboundStream, + ) -> ServiceResult { + Response::ok(types::Clone::default()) + } + + async fn bidi( + &self, + _ctx: RequestContext, + _requests: InboundStream, + ) -> ServiceResult> { + Response::stream_ok(futures::stream::empty()) + } +} + +/// Implements a single-RPC service from `shadow_services.proto`. Only `S` and +/// `T` are served. +macro_rules! impl_call { + ($($service:ident),*) => {$( + impl services::$service for Impl { + async fn call( + &self, + _ctx: RequestContext, + _request: ServiceRequest<'_, services::Request>, + ) -> ServiceResult { + Response::ok(services::Response::default()) + } + } + )*}; +} + +impl_call!(Box, Clone, Into, Option, S, Send, Sync, T); + +async fn serve(app: axum::Router) -> ClientConfig { + let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); + let addr = listener.local_addr().unwrap(); + tokio::spawn(async move { + axum::serve(listener, app).await.unwrap(); + }); + ClientConfig::new(format!("http://{addr}").parse().unwrap()) +} + +/// Calls each `GenericParamService` RPC once and returns the four responses. +async fn call_each(config: ClientConfig) -> [String; 4] { + let client = types::GenericParamServiceClient::new(HttpClient::plaintext(), config); + + let unary = client.unary(s("a".into())).await.unwrap().into_owned(); + + let mut stream = client.server_stream(t("b".into())).await.unwrap(); + let server_stream = stream.message().await.unwrap().unwrap(); + + let requests = futures::stream::iter([s("c".into()), s("d".into())]); + let client_stream = client.client_stream(requests).await.unwrap().into_owned(); + + let mut stream = client.bidi().await.unwrap(); + stream.send(t("e".into())).await.unwrap(); + stream.close_send(); + let bidi = stream.message().await.unwrap().unwrap(); + + [ + unary.value, + server_stream.view().value.to_owned(), + client_stream.value, + bidi.view().value.to_owned(), + ] +} + +const EXPECTED: [&str; 4] = ["unary a", "server_stream b", "client_stream c d", "bidi e"]; + +#[tokio::test] +async fn types_named_like_generic_params_through_the_router() { + let router = + Router::new().add_service::<_, types::GenericParamServiceRegisterMarker>(Arc::new(Impl)); + let config = serve(router.into_axum_router()).await; + assert_eq!(call_each(config).await, EXPECTED); +} + +#[tokio::test] +async fn types_named_like_generic_params_through_the_dispatcher() { + let service = ConnectRpcService::new(types::GenericParamServiceServer::new(Impl)); + let config = serve(axum::Router::new().fallback_service(service)).await; + assert_eq!(call_each(config).await, EXPECTED); +} + +#[tokio::test] +async fn types_named_like_prelude_items() { + let service = ConnectRpcService::new(types::PreludeServiceServer::new(Impl)); + let config = serve(axum::Router::new().fallback_service(service)).await; + let client = types::PreludeServiceClient::new(HttpClient::plaintext(), config); + + let request = types::Option { + value: "a".into(), + ..Default::default() + }; + let response: Result<_, ConnectError> = client.unary(request).await; + assert_eq!(response.unwrap().view().value, "unary a"); +} + +#[tokio::test] +async fn services_named_like_generic_params() { + use services::{SExt, TExt}; + + let service = Arc::new(Impl); + let router = SExt::register(Arc::clone(&service), Router::new()); + let router = TExt::register(service, router); + let config = serve(router.into_axum_router()).await; + + let request = services::Request::default; + let client = services::SClient::new(HttpClient::plaintext(), config.clone()); + client.call(request()).await.unwrap(); + let client = services::TClient::new(HttpClient::plaintext(), config.clone()); + client.call(request()).await.unwrap(); + + let service = ConnectRpcService::new(services::TServer::new(Impl)); + let config = serve(axum::Router::new().fallback_service(service)).await; + let client = services::TClient::new(HttpClient::plaintext(), config); + client.call(request()).await.unwrap(); +}