Skip to content

Commit

Permalink
fix(build): Remove default impl for Server traits (#229)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: remove default implementations for server traits.
  • Loading branch information
alce authored and LucioFranco committed Jan 13, 2020
1 parent dadc818 commit a41f55a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 12 deletions.
22 changes: 22 additions & 0 deletions examples/src/multiplex/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,27 @@ impl Echo for MyEcho {
}

type ServerStreamingEchoStream = ResponseStream;

async fn server_streaming_echo(
&self,
_: Request<EchoRequest>,
) -> Result<Response<Self::ServerStreamingEchoStream>, Status> {
Err(Status::unimplemented("Not yet implemented"))
}

async fn client_streaming_echo(
&self,
_: Request<tonic::Streaming<EchoRequest>>,
) -> Result<Response<EchoResponse>, Status> {
Err(Status::unimplemented("Not yet implemented"))
}

type BidirectionalStreamingEchoStream = ResponseStream;

async fn bidirectional_streaming_echo(
&self,
_: Request<tonic::Streaming<EchoRequest>>,
) -> Result<Response<Self::BidirectionalStreamingEchoStream>, Status> {
Err(Status::unimplemented("Not yet implemented"))
}
}
22 changes: 22 additions & 0 deletions examples/src/tls_client_auth/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,29 @@ impl pb::echo_server::Echo for EchoServer {
}

type ServerStreamingEchoStream = ResponseStream;

async fn server_streaming_echo(
&self,
_: Request<EchoRequest>,
) -> Result<Response<Self::ServerStreamingEchoStream>, Status> {
Err(Status::unimplemented("Not yet implemented"))
}

async fn client_streaming_echo(
&self,
_: Request<tonic::Streaming<EchoRequest>>,
) -> Result<Response<EchoResponse>, Status> {
Err(Status::unimplemented("Not yet implemented"))
}

type BidirectionalStreamingEchoStream = ResponseStream;

async fn bidirectional_streaming_echo(
&self,
_: Request<tonic::Streaming<EchoRequest>>,
) -> Result<Response<Self::BidirectionalStreamingEchoStream>, Status> {
Err(Status::unimplemented("Not yet implemented"))
}
}

#[tokio::main]
Expand Down
16 changes: 4 additions & 12 deletions tonic-build/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,14 @@ fn generate_trait_methods(service: &Service, proto_path: &str) -> TokenStream {
quote! {
#method_doc
async fn #name(&self, request: tonic::Request<#req_message>)
-> Result<tonic::Response<#res_message>, tonic::Status> {
Err(tonic::Status::unimplemented("Not yet implemented"))
}
-> Result<tonic::Response<#res_message>, tonic::Status>;
}
}
(true, false) => {
quote! {
#method_doc
async fn #name(&self, request: tonic::Request<tonic::Streaming<#req_message>>)
-> Result<tonic::Response<#res_message>, tonic::Status> {
Err(tonic::Status::unimplemented("Not yet implemented"))
}
-> Result<tonic::Response<#res_message>, tonic::Status>;
}
}
(false, true) => {
Expand All @@ -135,9 +131,7 @@ fn generate_trait_methods(service: &Service, proto_path: &str) -> TokenStream {

#method_doc
async fn #name(&self, request: tonic::Request<#req_message>)
-> Result<tonic::Response<Self::#stream>, tonic::Status> {
Err(tonic::Status::unimplemented("Not yet implemented"))
}
-> Result<tonic::Response<Self::#stream>, tonic::Status>;
}
}
(true, true) => {
Expand All @@ -153,9 +147,7 @@ fn generate_trait_methods(service: &Service, proto_path: &str) -> TokenStream {

#method_doc
async fn #name(&self, request: tonic::Request<tonic::Streaming<#req_message>>)
-> Result<tonic::Response<Self::#stream>, tonic::Status> {
Err(tonic::Status::unimplemented("Not yet implemented"))
}
-> Result<tonic::Response<Self::#stream>, tonic::Status>;
}
}
};
Expand Down

0 comments on commit a41f55a

Please sign in to comment.