/// The request message containing the user's name. #[derive(Clone, PartialEq, ::prost::Message)] pub struct HelloRequest { #[prost(string, tag = "1")] pub name: std::string::String, } /// The response message containing the greetings #[derive(Clone, PartialEq, ::prost::Message)] pub struct HelloReply { #[prost(string, tag = "1")] pub message: std::string::String, } #[doc = r" Generated client implementations."] pub mod client { #![allow(unused_variables, dead_code, missing_docs)] use tonic::codegen::*; #[doc = " The greeting service definition."] pub struct GreeterClient { inner: tonic::client::Grpc, } impl GreeterClient { #[doc = r" Attempt to create a new client by connecting to a given endpoint."] pub async fn connect(dst: D) -> Result where D: TryInto, D::Error: Into, { let conn = tonic::transport::Endpoint::new(dst)?.connect().await?; Ok(Self::new(conn)) } } impl GreeterClient where T: tonic::client::GrpcService, T::ResponseBody: Body + Send + 'static, T::Error: Into, ::Error: Into + Send, ::Data: Into + Send, { pub fn new(inner: T) -> Self { let inner = tonic::client::Grpc::new(inner); Self { inner } } #[doc = r" Check if the service is ready."] pub async fn ready(&mut self) -> Result<(), tonic::Status> { self.inner.ready().await.map_err(|e| { tonic::Status::new( tonic::Code::Unknown, format!("Service was not ready: {}", e.into()), ) }) } #[doc = " Sends a greeting"] pub async fn say_hello( &mut self, request: tonic::Request, ) -> Result, tonic::Status> { self.ready().await?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static("/helloworld.Greeter/SayHello"); self.inner.unary(request, path, codec).await } } impl Clone for GreeterClient { fn clone(&self) -> Self { Self { inner: self.inner.clone(), } } } } #[doc = r" Generated server implementations."] pub mod server { #![allow(unused_variables, dead_code, missing_docs)] use tonic::codegen::*; #[doc = "Generated trait containing gRPC methods that should be implemented for use with GreeterServer."] #[async_trait] pub trait Greeter: Send + Sync + 'static { #[doc = " Sends a greeting"] async fn say_hello( &self, request: tonic::Request, ) -> Result, tonic::Status> { Err(tonic::Status::unimplemented("Not yet implemented")) } } #[doc = " The greeting service definition."] #[derive(Clone, Debug)] pub struct GreeterServer { inner: Arc, } #[derive(Clone, Debug)] #[doc(hidden)] pub struct GreeterServerSvc { inner: Arc, } impl GreeterServer { #[doc = "Create a new GreeterServer from a type that implements Greeter."] pub fn new(inner: T) -> Self { let inner = Arc::new(inner); Self::from_shared(inner) } pub fn from_shared(inner: Arc) -> Self { Self { inner } } } impl GreeterServerSvc { pub fn new(inner: Arc) -> Self { Self { inner } } } impl Service for GreeterServer { type Response = GreeterServerSvc; type Error = Never; type Future = Ready>; fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } fn call(&mut self, _: R) -> Self::Future { ok(GreeterServerSvc::new(self.inner.clone())) } } impl Service> for GreeterServerSvc { type Response = http::Response; type Error = Never; type Future = BoxFuture; fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } fn call(&mut self, req: http::Request) -> Self::Future { let inner = self.inner.clone(); match req.uri().path() { "/helloworld.Greeter/SayHello" => { struct SayHello(pub Arc); impl tonic::server::UnaryService for SayHello { type Response = super::HelloReply; type Future = BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { inner.say_hello(request).await }; Box::pin(fut) } } let inner = self.inner.clone(); let fut = async move { let method = SayHello(inner); let codec = tonic::codec::ProstCodec::default(); let mut grpc = tonic::server::Grpc::new(codec); let res = grpc.unary(method, req).await; Ok(res) }; Box::pin(fut) } _ => Box::pin(async move { Ok(http::Response::builder() .status(200) .header("grpc-status", "12") .body(empty_body()) .unwrap()) }), } } } }