You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following error occurs when execute cargo build:
error[E0404]: expected trait, found struct `Foo`
--> /xxx/target/debug/build/xxx-16b05b8476663e11/out/foo.rs:126:35
|
126 | struct Foo<T: Foo>(pub Arc<T>);
| ^^^ not a trait
help: possible better candidate is found in another module, you can import it into scope
|
67 | use crate::proto::foo::server::Foo;
|
error[E0404]: expected trait, found struct `Foo`
--> /xxx/target/debug/build/xxx-16b05b8476663e11/out/foo.rs:127:29
|
127 | impl<T: Foo> tonic::server::StreamingService<super::FooRequest> for Foo<T> {
| ^^^ not a trait
help: possible better candidate is found in another module, you can import it into scope
|
67 | use crate::proto::foo::server::Foo;
And I notice there is a new struct named Foo in the generated rpc method, which conflicts with the previous defined trait Foo
The complete generated code:
#[derive(Clone,PartialEq,::prost::Message)]pubstructFooRequest{}#[derive(Clone,PartialEq,::prost::Message)]pubstructFooResponse{}#[doc = r" Generated client implementations."]pubmod client {#![allow(unused_variables, dead_code, missing_docs)]use tonic::codegen::*;pubstructFooClient<T>{inner: tonic::client::Grpc<T>,}implFooClient<tonic::transport::Channel>{#[doc = r" Attempt to create a new client by connecting to a given endpoint."]pubfnconnect<D>(dst:D) -> Result<Self, tonic::transport::Error>whereD: std::convert::TryInto<tonic::transport::Endpoint>,D::Error:Into<StdError>,{
tonic::transport::Endpoint::new(dst).map(|c| Self::new(c.channel()))}}impl<T>FooClient<T>whereT: tonic::client::GrpcService<tonic::body::BoxBody>,T::ResponseBody:Body + HttpBody + Send + 'static,T::Error:Into<StdError>,
<T::ResponseBodyasHttpBody>::Error:Into<StdError> + Send,
<T::ResponseBodyasHttpBody>::Data:Into<bytes::Bytes> + Send,{pubfnnew(inner:T) -> Self{let inner = tonic::client::Grpc::new(inner);Self{ inner }}#[doc = r" Check if the service is ready."]pubasyncfnready(&mutself) -> Result<(), tonic::Status>{self.inner.ready().await.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,format!("Service was not ready: {}", e.into()),)})}pubasyncfnfoo<S>(&mutself,request: tonic::Request<S>,) -> Result<tonic::Response<tonic::codec::Streaming<super::FooResponse>>, tonic::Status>whereS:Stream<Item = Result<super::FooRequest, tonic::Status>> + Send + 'static,{self.ready().await?;let codec = tonic::codec::ProstCodec::new();let path = http::uri::PathAndQuery::from_static("/foo.Foo/Foo");self.inner.streaming(request, path, codec).await}}impl<T:Clone>CloneforFooClient<T>{fnclone(&self) -> Self{Self{inner:self.inner.clone(),}}}}#[doc = r" Generated server implementations."]pubmod server {#![allow(unused_variables, dead_code, missing_docs)]use tonic::codegen::*;#[doc = "Generated trait containing gRPC methods that should be implemented for use with FooServer."]#[async_trait]pubtraitFoo:Send + Sync + 'static {#[doc = "Server streaming response type for the Foo method."]typeFooStream:Stream<Item = Result<super::FooResponse, tonic::Status>> + Send + 'static;asyncfnfoo(&self,request: tonic::Request<tonic::Streaming<super::FooRequest>>,) -> Result<tonic::Response<Self::FooStream>, tonic::Status>{Err(tonic::Status::unimplemented("Not yet implemented"))}}#[derive(Clone,Debug)]pubstructFooServer<T:Foo>{inner:Arc<T>,}#[derive(Clone,Debug)]#[doc(hidden)]pubstructFooServerSvc<T:Foo>{inner:Arc<T>,}impl<T:Foo>FooServer<T>{#[doc = "Create a new FooServer from a type that implements Foo."]pubfnnew(inner:T) -> Self{let inner = Arc::new(inner);Self::from_shared(inner)}pubfnfrom_shared(inner:Arc<T>) -> Self{Self{ inner }}}impl<T:Foo>FooServerSvc<T>{pubfnnew(inner:Arc<T>) -> Self{Self{ inner }}}impl<T:Foo,R>Service<R>forFooServer<T>{typeResponse = FooServerSvc<T>;typeError = Never;typeFuture = Ready<Result<Self::Response,Self::Error>>;fnpoll_ready(&mutself,_cx:&mutContext<'_>) -> Poll<Result<(),Self::Error>>{Poll::Ready(Ok(()))}fncall(&mutself, _:R) -> Self::Future{ok(FooServerSvc::new(self.inner.clone()))}}impl<T:Foo>Service<http::Request<HyperBody>>forFooServerSvc<T>{typeResponse = http::Response<tonic::body::BoxBody>;typeError = Never;typeFuture = BoxFuture<Self::Response,Self::Error>;fnpoll_ready(&mutself,_cx:&mutContext<'_>) -> Poll<Result<(),Self::Error>>{Poll::Ready(Ok(()))}fncall(&mutself,req: http::Request<HyperBody>) -> Self::Future{let inner = self.inner.clone();match req.uri().path(){"/foo.Foo/Foo" => {structFoo<T:Foo>(pubArc<T>);impl<T:Foo> tonic::server::StreamingService<super::FooRequest>forFoo<T>{typeResponse = super::FooResponse;typeResponseStream = T::FooStream;typeFuture =
BoxFuture<tonic::Response<Self::ResponseStream>, tonic::Status>;fncall(&mutself,request: tonic::Request<tonic::Streaming<super::FooRequest>>,) -> Self::Future{let inner = self.0.clone();let fut = asyncmove{ inner.foo(request).await};Box::pin(fut)}}let inner = self.inner.clone();let fut = asyncmove{let method = Foo(inner);let codec = tonic::codec::ProstCodec::new();letmut grpc = tonic::server::Grpc::new(codec);let res = grpc.streaming(method, req).await;Ok(res)};Box::pin(fut)}
_ => Box::pin(asyncmove{Ok(http::Response::builder().status(200).header("grpc-status","12").body(tonic::body::BoxBody::empty()).unwrap())}),}}}}
The text was updated successfully, but these errors were encountered:
Bug Report
Version
Platform
Linux cccjlx 5.3.7-arch1-1-ARCH #1 SMP PREEMPT Fri Oct 18 00:17:03 UTC 2019 x86_64 GNU/Linux
Crates
tonic-build
Description
Proto buffers definition:
The following error occurs when execute
cargo build
:And I notice there is a new struct named
Foo
in the generated rpc method, which conflicts with the previous defined traitFoo
The complete generated code:
The text was updated successfully, but these errors were encountered: